Font size
WorksheetsJavaScript - Practice 8
Total questions: 40
Worksheet time: 21mins
Which of the following is an extension of JavaScript file?
.jp
.jt
How important is the JavaScript in web development?
It decorates the webpages effectively
It makes the website more interactive and user-friendliness
It makes the front-end of a website
It is the standard markup language for creating web pages
How do you get JavaScript on your computer?
You don't have to get or download JavaScript because it is already running in your browser
You have to download a JavaScript editor to run JavaScript code
You have to download Node.js runtime to run JavaScript code
You don't have to get it because your operating system is written in JavaScript
Can JavaScript change HTML content?
No
Yes
How to find an HTML element by its id?
document.getElementById()
document.getElementByIDd()
document.getElementsById()
document.getElementByClassName()
Which of the following symbols is used for JavaScript comments?
<!-- -->
Indicates the beginning and the end of the JavaScript section in HTML files.
How to show a pop-up message to the user on browser?
alert
prompt
console.log
<p> tag
Console.WriteLine
Which message will the user see on browser?
Nothing to show
How to declare a new variable in JavaScript?
Write an expression in if-statement
"His name is Fred and he is less than 16 years old"
if (name = "fred" && age < 16 )
if (name === "fred" && age < 16 )
if (name = "fred" || age < 16 )
if (name === "fred" || age < 16 )
if (name == 'Fred' && age < 16)
A variable can be declared with keyword (a)
What is an array?
List of data
What type of variable:
var age = "5";
int
float
boolean
string
number
What is the first index value of an array?
2
-1
0
1
What is an alert box in browser?
alert("Hello world!");
The alert box takes the focus away from the current window, and forces the user to read the message.
It warns (someone) of a danger, threat, or problem, typically with the intention of having it avoided or dealt with.
An area on a page that is to be filled in or that is set off by a border.
The state of being watchful for possible danger.
What will this code display?
8, 2, 1, 4, 7
82147
Myarray.length
5
6
What would this piece of code do?
change the background color of the word demo to red
change the font color of the demo element to red
this is not correct
style the element with the class demo
set the text in demo element
Which of these is a method?
getElementById( )
style
document
color
getElementsById( )
Which of the following is the correct JavaScript format for a comment?
// the text
/the text/
*/the text/*
\\the text
# the text
What is the correct data type of the variable x?
(a)
Fill in the blank to complete the function in JavaScript
(a)
JavaScript : What is the alert display for text3 ?
John Doe
JohnDoe
"John" " " "Doe"
"JohnDoe"
What will be the output?
console.log(1 === '1');
true
false
What will be the output?
console.log(1 == '1');
true
false
What will be the output?
console.log(1 == '01');
true
false
What will be the output?
console.log('8' + 7);
15
87
some error
What will be the output?
console.log(8 + '7');
15
87
some error
What will be the output?
console.log(10 / 0);
some error
Infinity
0
What will be the output?
console.log('' == 0); //there is an empty string on the statement
true
false
What will be the output?
console.log(NaN == NaN);
true
false
What will be the output?
let number = 0;
console.log(number++);
console.log(++number);
console.log(number);
1
2
2
0
2
2
0
1
2
What will be the output?
const obj = { a: 'one', b: 'two', a: 'three' };
console.log(obj);
some error
{ a: 'three', b: 'two'}
{ a: 'one', b: 'two', a: 'three' }
Select the falsy values!
(more than one correct answer is possible)
''
'1'
0
null
true
What will be console logged into the terminal?
1
2
{number: 1}
3
What property tells you how many items are in an array?
count
sum
length
items
What will this code log?
3
undefined
1,2,3,4
arr
Which of the following code will return `undefined` using the following array?
const numbers = [3, 1];
numbers[0]
numbers[2-1]
numbers[3]
numbers[numbers.length -1]
All the elements in an array must be of the same type?
True
False
Yes
