JS 2 Flashcards
Which event occurs when the user clicks on an HTML element?
onclick
How to write an IF statement for executing some code if “i” is NOT equal to 5?
if (i != 5)
How do you write “Hello World” in an alert box?
alert(“Hello World”);
What is the correct way to write a JavaScript array?
var colors = [“red”, “green”, “blue”]
How to insert a comment that has more than one line?
//This comment has……more than one line//
/This comment has…….more than one line/
<!--This comment has......more than one line-->
What is the correct JavaScript syntax to change the content of the HTML element below?
<p>This is a demonstration.</p>
demo.innerHTML = “Hello World!”;
document.getElementByName(“p”).innerHTML = “Hello World!”;
document.getElement(“p”).innerHTML = “Hello World!”;
document.getElementById(“demo”).innerHTML = “Hello World!”;
How can you add a comment in a JavaScript?
<!--This is a comment-->
//This is a comment
‘This is a comment
Which operator is used to assign a value to a variable?
*
-
x