0% found this document useful (0 votes)
65 views4 pages

Js Final

The document contains questions about JavaScript syntax and concepts. The key points are: 1) The <script> element is used to contain JavaScript code. 2) The getElementById method accesses an element by ID and is used to change its innerHTML property. 3) JavaScript code can be inserted in the <head> or <body> sections. 4) The <script> tag is not needed in external JavaScript files, which use the src attribute to link to a .js file. 5) JavaScript is case-sensitive. So in summary, the document tests knowledge of basic JavaScript syntax, elements, and concepts.

Uploaded by

Pol Asuncion
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views4 pages

Js Final

The document contains questions about JavaScript syntax and concepts. The key points are: 1) The <script> element is used to contain JavaScript code. 2) The getElementById method accesses an element by ID and is used to change its innerHTML property. 3) JavaScript code can be inserted in the <head> or <body> sections. 4) The <script> tag is not needed in external JavaScript files, which use the src attribute to link to a .js file. 5) JavaScript is case-sensitive. So in summary, the document tests knowledge of basic JavaScript syntax, elements, and concepts.

Uploaded by

Pol Asuncion
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

1. Inside which HTML element do we put the JavaScript?

<javascript>
<scripting>
<script>
<js>

2. What is the correct JavaScript syntax to change the content of the HTML
element below?

<p id="demo">This is a demonstration.</p>

document.getElement("p").innerHTML = "Hello World!";


document.getElementByName("p").innerHTML = "Hello World!";
document.getElementById("demo").innerHTML = "Hello World!";
#demo.innerHTML = "Hello World!";

3. Where is the correct place to insert a JavaScript?

Both the <head> section and the <body> section are correct
The <body> section
The <head> section

4. What is the correct syntax for referring to an external script called


"xxx.js"?

<script href="xxx.js">
<script src="xxx.js">
<script name="xxx.js">

5. The external JavaScript file must contain the <script> tag.

True
False
6. How do you write "Hello World" in an alert box?

alert("Hello World");
alertBox("Hello World");
msg("Hello World");
msgBox("Hello World");

7. How do you create a function in JavaScript?

function = myFunction()
function myFunction()
function:myFunction()

8. How do you call a function named "myFunction"?

myFunction()
call myFunction()
call function myFunction()

10. How to write an IF statement for executing some code if "i" is NOT equal
to 5?

if (i <> 5)
if i <> 5
if (i != 5)
if i =! 5 then

11. How does a WHILE loop start?

while (i <= 10; i++)


while (i <= 10)
while i = 1 to 10

12. How does a FOR loop start?


for (i = 0; i <= 5)
for (i = 0; i <= 5; i++)
for i = 1 to 5
for (i <= 5; i++)

13. How can you add a comment in a JavaScript?

'This is a comment
//This is a comment
<!--This is a comment-->

14. 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*/

15. What is the correct way to write a JavaScript array?

var colors = ["red", "green", "blue"]


var colors = "red", "green", "blue"
var colors = 1 = ("red"), 2 = ("green"), 3 = ("blue")
var colors = (1:"red", 2:"green", 3:"blue")

19. JavaScript is the same as Java.

False
True

22. How do you declare a JavaScript variable?

v carName;
var carName;
variable carName;

23. Which operator is used to assign a value to a variable?

-
=
x
*

25. Is JavaScript case-sensitive?

No
Yes

You might also like