Uncategorized Flashcards
(55 cards)
Inside which HTML element do we put the JavaScript?
A)
B)
C)
D)
C)
What is the correct JavaScript syntax to change the content of the HTML element below?
<p>This is a demonstration.</p>
A) document.getElementByName(“p”).innerHTML = “Hello World!”;
B) document.getElementById(“demo”).innerHTML = “Hello World!”;
C)#demo.innerHTML = “Hello World!”;
D)document.getElement(“p”).innerHTML = “Hello World!”;
B) document.getElementById(“demo”).innerHTML = “Hello World!”;
Where is the correct place to insert a JavaScript?
A) The section
B) The section
C) Both the section and the section are correct
C) Both the section and the section are correct
What is the correct syntax for referring to an external script called “xxx.js”?
A)
B)
C)
A)
The external JavaScript file must contain the tag.
A) True
B) False
B) False
How do you write “Hello World” in an alert box?
A) alert(“Hello World”);
B) msgBox(“Hello World”);
C) alertBox(“Hello World”);
D) msg(“Hello World”);
A) alert(“Hello World”);
How do you create a function in JavaScript?
A) function myFunction()
B) function = myFunction()
C) function:myFunction()
A) function myFunction()
How do you call a function named “myFunction”?
A) call function myFunction()
B) myFunction()
C) call myFunction()
B) myFunction()
How to write an IF statement in JavaScript?
A) if i == 5 then
B) if i = 5
C) if i = 5 then
D) if (i == 5)
D) if (i == 5)
How to write an IF statement for executing some code if “i” is NOT equal to 5?
A) if i <> 5
B) if (i != 5)
C) if (i <> 5)
D) if i =! 5 then
B) if (i != 5)
How does a WHILE loop start?
A) while (i <= 10)
B) while i = 1 to 10
C) while (i <= 10; i++)
A) while (i <= 10)
How does a FOR loop start?
A) for (i = 0; i <= 5)
B) for (i = 0; i <= 5; i++)
C) for i = 1 to 5
D) for (i <= 5; i++)
B) for (i = 0; i <= 5; i++)
How can you add a comment in a JavaScript?
A) ‘This is a comment
B)
C) //This is a comment
C) //This is a comment
How to insert a comment that has more than one line?
A) //This comment has more than one line// B) /*This comment has more than one line*/ C)
B) /*This comment has
more than one line*/
What is the correct way to write a JavaScript array?
A) var colors = "red", "green", "blue" B) var colors = ["red", "green", "blue"] C) var colors = 1 = ("red"), 2 = ("green"), 3 = ("blue") D) var colors = (1:"red", 2:"green", 3:"blue")
B) var colors = [“red”, “green”, “blue”]
How do you round the number 7.25, to the nearest integer?
A) round(7.25)
B) rnd(7.25)
C) Math.round(7.25)
D) Math.rnd(7.25)
C) Math.round(7.25)
How do you find the number with the highest value of x and y?
A) Math.max(x, y)
B) top(x, y)
C) Math.ceil(x, y)
D) ceil(x, y)
A) Math.max(x, y)
What is the correct JavaScript syntax for opening a new window called “w2” ?
A) w2 = window.new(“http://www.w3schools.com”);
B) w2 = window.open(“http://www.w3schools.com”);
B) w2 = window.open(“http://www.w3schools.com”);
How can you detect the client’s browser name?
A) navigator.appName
B) client.navName
C) browser.name
A) navigator.appName
Which event occurs when the user clicks on an HTML element?
A) onmouseclick
B) onmouseover
C) onclick
D) onchange
C) onclick
What will the following code return: Boolean(10 > 9)
A) false
B) true
C) NaN
B) true
Is JavaScript case-sensitive?
A) Yes
B) No
A) Yes
Is JavaScript multi-threaded or single-threaded?
A) Single-threaded
B) Multi-threaded
A) Single-threaded
How can you get the total number of arguments passed to a function?
A - Using args.length property
B - Using arguments.length property
C - Both of the above.
D - None of the above.
B - Using arguments.length property