JS Input Output

Beside using html and javascript file, to test javascript you can use tools in Firefox or Chrome Web Browser. In firefox just click : Tools -> Web Developer -> Web Console. Then type alert(“Alert From Web Console”) . In Chrome click : icon in the right top -> More Tools -> Developer Tools -> Console -> Console then type alert(“Alert From Console”);


To show output the easy way is using alert , document.write and console.log . An alert is a box which popup to give warning / message to user. The example code is :

alert("Hello World, This is Alert");

To show console.log you can use in Firefox : Tools -> Web Developer -> Web Console. Then type :

console.log("This is console");

It’s very usefull if you want to debug your javascript code.

document.write("This is from document write");


For input you can use prompt and confirm . The prompt is a pop up dialog/box which asking for text input . You can use like this :

prompt("How old are you");

Confirm is command to asking user input by asking yes or no question. Here is example using it :

confirm("Do you like the president ?");

View Demo