Worksheets1B Tynker JavaScript
Total questions: 23
Worksheet time: 13mins
An identifier cannot begin with a number. Which of the following is NOT a valid identifier?
_identifier
$IDENTIFIER
1identifier
Identifier1
How would you call a function called “myFunction”?
myfunction();
myFunction();
Call myFunction();
call function myFunction();
Identifiers in JavaScript are case-sensitive.
True
False
You are not able to call the same function twice in a row.
True
False
Which of the following is a correct multi-line comment?
*/ hello
World */
*/ hello
World /*
/*hello
World /*
/* hello
World */
In JavaScript, an identifier may begin with an underscore, a letter, or a dollar sign. Which of the following is a valid identifier? Select all that apply.
IDENT20
_ident
$ident1
20IDENT
Commented lines affect the execution of your program.
True
False
An identifier can begin with a number.
True
False
78090 is a valid identifier in JavaScript.
True
False
Both of the following are valid ways to comment code:
//hello
//world
/*hello
world*/
True
False
How far will a ship move using the following code?
for (i = 1; i < 5; i++) {
forward();
}
3
6
4
5
Which is the correct syntax to make a "for" loop run for all numbers from 0 to 10?
for(i = 0; i <= 10; i++)
for(i = 10; i = 0; i--)
for(i = 1; i < 10; i++)
for(i = 0; i < 10; i++)
The following code will print "hello" 25 times.
for (i = 0; i < 5; i++) {
for(i = 0; i < 5; i++) {
print("hello");
}
}
True
False
The following "for" loop has correct syntax.
for (i = 0, i = 5, i++)
True
False
How many times will the following "for" loop execute?
for (i = 10; i > 5; i++)
20
5
Infinite
10
Choose the following "for" loops that does. not repeat 5 times.
for (i = 5; i < 10; i++)
for(i = 0; i <= 5; i++)
for(i = 0; i < 5; i++)
for(i = 1; i < 10; i = i + 2)
"For" loops can increment upwards or downwards.
True
False
Which "for" loop will move a ship 5 times?
for(i = 0; i < 5; i++) {
forward();
}
for(i = 0; i < 6; i++) {
forward();
}
for(i = 1; i < 3; i++) {
forward();
}
for(i = 1; i <5; i++) {
forward();
}
Which of the following produce errors in JavaScript?
Commenting incorrectly
Naming variables and functions without the camelCase naming convention
Indenting incorrectly
All of the above
What will the following "for" loop print?
for(i = 0; i < 2; i++) {
print('a');
aaaa
aa
aaa
a
Which part of a conditional goes in the parentheses?
The word “if”
The word “else”
The code to run
The condition
There is no difference between an "if" statement and an "if-else" statement.
True
False
If you wanted to run different code given different conditions, how would you do that?
Combine all the conditions in one condition using “or”
Use “else if” statements
Put everything in the “else” statement
Create two functions
