Hello Romeo,
Probably you no need to use pure Javascript to do what you wanted. You can take a look at these two samples: "Promt" and "InputBox". Both of these samples ask to the user for something (a password, for example), and then, using the appropriate app's function (callback) process the user's input in the way that we need.
The problem here are not to ask the user for some password, the problem can be to store that password in the same app. Since our apps are clients apps, somebody can take it an decompile it (for example, if we distribute the app as an APK for Android) and then take the clear password, modify the app behaviour, etc.
In principle, our apps never must store private information inside the app's code, files, etc.. If we need to deal with private information we must store that information in an app's server, and then, serve that private information only when required, for example, when the app's user login in our app's server. Then, if we can't login... we never can reach the private information.
Of course, all the above depend on what you really wanted. Maybe the password that you want to use is not very important, or, is a kind of "game", that is, is not important if someone get the password by decompile the app. In this case, there is no problem to ask the user for a password, and you can use the Promt or the InputBox actions, or just create an app's view that you can use in a "dialog" or in an normal way.
Take a look at the Promt and the InputBox samples, and, if you have any further questions, please, post it here Romeo.