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”)