Javascript Flashcards
Inside which HTML element do we put the JavaScript?
script
What is the correct JavaScript syntax to write “Hello World”?
document.write(“Hello World”)
Where is the correct place to insert a JavaScript?
Both the head section and the section are correct
What is the correct syntax for referring to an external script called “xxx.js”?
script type=”text/javascript” src=”xxx.js”
The external JavaScript file must contain the script tag
False
How do you write “Hello World” in an alert box?
alert(“Hello World”)
How do you create a function?
function myFunction()
How do you call a function named “myFunction”?
myFunction()
How do you write a conditional statement for executing some code if “i” is equal to 5?
if (i==5)
How do you write a conditional statement for executing some code if “i” is NOT equal to 5?
if (i != 5)
How does a “while” loop start?
while (i<=10)
How does a “for” loop start?
for (i = 0; i <= 5; i++)
How can you add a comment in a JavaScript?
//This is a comment
What is the correct JavaScript syntax to insert a comment that has more than one line?
/*This comment has more than one line*/
What is the correct way to write a JavaScript array?
var txt = new Array(“tim”,”kim”,”jim”)
How do you round the number 7.25, to the nearest integer?
Math.round(7.25)
How do you find the number with the highest value of x and y?
Math.max(x,y)
What is the correct JavaScript syntax for opening a new window called “w2” ?
w2=window.open(“http://www.w3schools.com”);
How do you put a message in the browser’s status bar?
window.status = “put your message here”
How can you find a client’s browser name?
navigator.appName