Javascript Flashcards

1
Q

Inside which HTML element do we put the JavaScript?

A

script

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the correct JavaScript syntax to write “Hello World”?

A

document.write(“Hello World”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Where is the correct place to insert a JavaScript?

A

Both the head section and the section are correct

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the correct syntax for referring to an external script called “xxx.js”?

A

script type=”text/javascript” src=”xxx.js”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

The external JavaScript file must contain the script tag

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How do you write “Hello World” in an alert box?

A

alert(“Hello World”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do you create a function?

A

function myFunction()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How do you call a function named “myFunction”?

A

myFunction()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How do you write a conditional statement for executing some code if “i” is equal to 5?

A

if (i==5)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How do you write a conditional statement for executing some code if “i” is NOT equal to 5?

A

if (i != 5)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How does a “while” loop start?

A

while (i<=10)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How does a “for” loop start?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How can you add a comment in a JavaScript?

A

//This is a comment

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the correct JavaScript syntax to insert a comment that has more than one line?

A
/*This comment has
more than one line*/
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the correct way to write a JavaScript array?

A

var txt = new Array(“tim”,”kim”,”jim”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How do you round the number 7.25, to the nearest integer?

A

Math.round(7.25)

17
Q

How do you find the number with the highest value of x and y?

A

Math.max(x,y)

18
Q

What is the correct JavaScript syntax for opening a new window called “w2” ?

A

w2=window.open(“http://www.w3schools.com”);

19
Q

How do you put a message in the browser’s status bar?

A

window.status = “put your message here”

20
Q

How can you find a client’s browser name?

A

navigator.appName