Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Javascript is one of the most prominent web programming languages that really made a difference. This course aims to be a useful companion for anyone wishing to (re)discover the many facets of JavaScript. Walk with us as we take you on a journey filled with all the wonders of Javascript including:
– Basics of JavaScript with ES6
– How to traverse the DOM?
– Modify Pages and handle events
– Animate elements
You will also learn how to build a Social News web application from scratch using the three web technologies HTML, CSS and JavaScript. Before moving on to advanced concepts, we will go through the fundamentals to get a strong grip over the basics. You can also experiment with the code provided and hence, gain a higher understanding of how things work. This course is perfect for anyone who wants to learn web development and get off to a good start in the JavaScript universe or catch up with its newest evolutions. Let’s walk this (JavaScript) way!
Q1. Following JavaScript command shows a message in the console, an information zone available in most JavaScript environments.
console.show()
console.log()
console.print()
log.show()
Q2. Is the following statement correct?
The JavaScript language uses the number type to represent a numerical value (with or without decimals) and the string type to represent text.
Q3. Observe the following program and choose the correct output:
console.log(4 / 8);
console.log("4 / 8");
console.log("4" / "8");
Q4. Applied to two strings, the +
operator performs addition if strings contain numeric values.
Q5. Is the following statement correct?
A computer program is made of several lines of code read sequentially during execution.
Q6. Is the following statement correct?
Comments (// ...
or /* ... */
) are non-executable parts of code.
Q7. In JavaScript, a string can be only surrounded by a pair of single quotes ('...'
).
Q8. Observe the following program and choose the correct output:
console.log("My name is");
/*
Jane
*/
console.log("\n, what is your name?");
Q1. Choose a correct option:
=
--
can increment their value by 1Q2. Observe the following program and try to predict the final values of its variables:
let a = 2;
a -= 1;
a++;
let b = 8;
b += 2;
const c = a + b * b;
const d = a * b + b;
const e = a * (b + b);
const f = a * b / a;
const g = b / a * a;
console.log(a, b, c, d, e, f, g);
a = 2
, b = 10
, c = 100
, d = 25
, e = 30
, f = 12
, g = 10
a = 2
, b = 10
, c = 102
, d = 30
, e = 40
, f = 10
, g = 10
a = 2
, b = 10
, c = 101
, d = 25
, e = 30
, f = 10
, g = 10
a = 2
, b = 10
, c = 100
, d = 30
, e = 40
, f = 12
, g = 10
Q3. Choose a correct option:
let
keyword followed by the variable nameconst
keywordlet
or const
are block-scopedQ4. Choose a correct option:
prompt()
and alert()
commands deal with information input and display under the form of dialog boxesNumber()
and String()
commands, to obtain respectively a number or a stringQ5. Is the following statement correct:
Type conversions can be done explicitly when using the Number()
and String()
commands
Q6. Observe the following program and choose the correct output:
const y = 7;
console.log(String(7) + 1);
Q1. Choose a correct option:
>
and <
>
and <
returns a boolean result==
is preferred to ===
and !=
is preferred to !==
Q2. Choose a correct if-else condition:
if{
}else(condition){
}
if(condition){
}else(condition){
}
if(condition){
}else{
}
if{
}else{
}
Q3. Is the following statement correct?
Complex conditions can be created using the logical operators &
(“and”), |
(“or”) and !
(“not”).
Q4. Choose a correct switch statement:
switch{
case value1:
break;
case value2:
break;
default:
}
switch (expression) {
case value1:
break;
case value2:
break;
default:
}
switch (expression) {
case value1;
break;
case value2;
break;
default;
}
switch (expression) {
case value1:
break:
case value2:
default:
}
Q5. Take a look at the following program:
let nb1 = Number(prompt("Enter nb1:"));
let nb2 = Number(prompt("Enter nb2:"));
let nb3 = Number(prompt("Enter nb3:"));
if (nb1 > nb2) {
nb1 = nb3 * 2;
} else {
nb1++;
if (nb2 > nb3) {
nb1 += nb3 * 3;
} else {
nb1 = 0;
nb3 = nb3 * 2 + nb2;
}
}
console.log(nb1, nb2, nb3);
Try to guess the final values of variables nb1
,nb2
and nb3
depending on following initial values:
nb1 = 4
nb2 = 4
nb3 = 4
Q6. Take a look at the following program:
let nb1 = Number(prompt("Enter nb1:"));
let nb2 = Number(prompt("Enter nb2:"));
let nb3 = Number(prompt("Enter nb3:"));
if (nb1 > nb2) {
nb1 = nb3 * 2;
} else {
nb1++;
if (nb2 > nb3) {
nb1 += nb3 * 3;
} else {
nb1 = 0;
nb3 = nb3 * 2 + nb2;
}
}
console.log(nb1, nb2, nb3);
Try to guess the final values of variables nb1
,nb2
and nb3
depending on following initial values:
nb1 = 2
nb2 = 4
nb3 = 0
Q7. Take a look at the following program:
let nb1 = Number(prompt("Enter nb1:"));
let nb2 = Number(prompt("Enter nb2:"));
let nb3 = Number(prompt("Enter nb3:"));
if (nb1 > nb2) {
nb1 = nb3 * 2;
} else {
nb1++;
if (nb2 > nb3) {
nb1 += nb3 * 3;
} else {
nb1 = 0;
nb3 = nb3 * 2 + nb2;
}
}
console.log(nb1, nb2, nb3);
Try to guess the final values of variables nb1
,nb2
and nb3
depending on following initial values:
nb1 = 4
nb2 = 3
nb3 = 2
Q1. Is the following statement correct?
Loops are used to repeat a series of statements and each repetition is called an iteration.
Q2. Is the following statement correct?
When we don’t know in advance how many times loop is going to run, for
loop is preferred.
Q3. Choose a correct option:
for
loop inside its body is a bad ideawhile
Q4. Choose a correct while
loop:
while(){
}
while(condition){
}
while{
}(condition)
Q5. Choose a correct for
loop:
for (initialization; condition; final expression){
}
initialization;
for (;condition; final expression){
}
for (;;){
}
Q6. What the given program will print?
let number = 200;
while (number > 100) {
console.log(number);
number--;
}
Choose the correct option:
Q7. What the given program will print?
for(let number=0; number < 10; number++)
{
console.log(number);
number++;
}
Choose the correct option:
Q1. Choose the correct option
func
keywordQ2. Choose the correct option:
global variables
Q3. Choose the correct option:
return
statement inside the function body defines the return value of the functionQ4. Choose the correct format for function declaration
:
const myFunc = function(param1, param2, ...) {
// Function code using param1, param2, ...
};
// Function call
myFunc(arg1, arg2, ...);
const myFunc = (param1, param2, ...) => {
// Function code using param1, param2, ...
};
// Function call
myFunc(arg1, arg2, ...);
function myFunction(param1, param2, ...) {
// Function code using param1, param2, ...
}
// Function call
myFunction(arg1, arg2, ...);
Q5. Choose the correct format for anonymous function
:
const myFunc = function(param1, param2, ...) {
// Function code using param1, param2, ...
};
// Function call
myFunc(arg1, arg2, ...);
const myFunc = (param1, param2, ...) => {
// Function code using param1, param2, ...
};
// Function call
myFunc(arg1, arg2, ...);
function myFunction(param1, param2, ...) {
// Function code using param1, param2, ...
}
// Function call
myFunction(arg1, arg2, ...);
Q6. Choose the correct format for arrow syntax
:
const myFunc = function(param1, param2, ...) {
// Function code using param1, param2, ...
};
// Function call
myFunc(arg1, arg2, ...);
const myFunc = (param1, param2, ...) => {
// Function code using param1, param2, ...
};
// Function call
myFunc(arg1, arg2, ...);
function myFunction(param1, param2, ...) {
// Function code using param1, param2, ...
}
// Function call
myFunction(arg1, arg2, ...);
Q7. Choose the correct output for the following program:
function sayHello() {
const message = "Hello!";
return message;
}
console.log(message); // Error: the message variable is not visible here
Q1. Choose the correct option:
console
and Math
are one of the JavaScript pre defined objectsQ2. Choose the correct format of creating object-literal in JavaScript:
this
keyword represents the object on which the method is called;
is compulsory to write at the end of object-literalQ3. Choose the correct format of creating object-literal in JavaScript:
const myObject = {
property1: value1;
property2: value2;
method1(/* ... */) {
// ...
};
method2(/* ... */) {
// ...
};
// ...
};
const myObject = {
property1: value1,
property2: value2,
method1(/* ... */) {
// ...
},
method2(/* ... */) {
// ...
}
// ...
};
const myObject = {
property1 => value1,
property2 => value2,
method1(/* ... */) {
// ...
};
method2(/* ... */) {
// ...
};
// ...
};
const myObject = {
property1: value1
property2: value2
method1(/* ... */) {
// ...
}
method2(/* ... */) {
// ...
}
// ...
};
Q4. Choose the correct output:
const pen = {
type: "ballpoint",
color: "blue",
brand: "Bic"
};
pen.price = "2.5";
console.log(`My pen costs ${pen.price}`);
Q5. Choose the correct output:
const pen = {
type: "ballpoint",
color: "blue",
brand: "Bic",
price: 3
};
pen.price = 4;
console.log(`My pen costs ${pen.price}`);
Q1. Choose the correct option:
size
property is used to get the number of elements of the array{}
Q2. Choose the correct option:
for in
looppush()
method adds an element at the beginning of the arraypop()
and splice()
are used to remove elements from the arrayQ3. Choose the correct output:
const alphabets = ["A", "B", "C"];
alphabets.splice(0, 1);
console.log(alphabets[1]);
Q4. Choose the correct output:
const alphabets = ["A", "B", "C"];
alphabets.pop();
console.log(alphabets[2]);
Q5. Choose the correct output:
const alphabets = ["A", "B", "C"];
alphabets.push("D");
console.log(alphabets[0] + "," + alphabets[3]);
Q6. Choose the correct output:
const alphabets = ["A", "B", "C"];
alphabets.unshift("D");
console.log(alphabets[0] + "," + alphabets[3]);
Q7. Which of the following for
loops will execute to the end of the array.
Choose the correct option:
for (let i = 0; i <= myArray.length; i++) {
// Use myArray[i] to access each array element one by one
}
for (let i = 0; i < myArray.size(); i++) {
// Use myArray[i] to access each array element one by one
}
for (let i = myArray.length - 1; i >= 0; i--) {
// Use myArray[i] to access each array element one by one
}
Q8. Identify which of the following is correct for each
loop?
Choose the correct option:
myArray.forEach(myElement => (
// Use myElement to access each array element one by one
));
myArray.forEach(myElement => {
// Use myElement to access each array element one by one
});
myArray.for(myElement => {
// Use myElement to access each array element one by one
});
Q9. Identify which of the following is a correct for-of loop?
Choose the correct option:
for (const myElement in myArray) {
// Use myElement to access each array element one by one
}
for (const myElement of myArray) {
// Use myElement to access each array element one by one
}
forEach (const myElement in myArray) {
// Use myElement to access each array element one by one
}
Q1. Choose the correct option:
===
operator, which is case sensitive.for
or a for-in
loopQ2. Choose the correct option:
splice()
method breaks a string into subparts delimited by a separatorindexOf()
, startsWith()
, and endsWith()
methodsArray.to()
method can be used to turn a string into an arrayQ3. Choose the correct option:
length
property returns the number of characters of the stringtoLower()
and toUpper()
methods respectively return new converted strings to lower and upper caseQ4. Choose the correct output:
const name = "Berlin";
console.log(name[6]);
Q5. The following code snippets produce same result:
const name = "Sarah";
for (let i = 0; i < name.length; i++) {
console.log(name[i]);
}
const name = "Sarah";
for (const letter of name) {
console.log(letter);
}
Q6. Choose the correct output for the following code snippet:
const alphabets = "A,B,C,D";
const result = alphabets.split(";");
console.log(result[0]);
Q7. Choose the correct output for the following code snippet:
const alphabets = "A,B,C,D";
const result = alphabets.split("B");
console.log(result[1]);
Q1. Choose the correct option:
class
can contain methods and propertiesnew
operatorQ2. Choose the correct option:
class
keyword, followed by curly braces.Object.link()
is a way to create and link JavaScript objects through prototypes.Q3. Choose the correct format to declare a class in JavaScript:
class MyClass {
constructor(param1, param2, ...) {
this.property1: param1,
this.property2: param2
// ...
}
method1(/* ... */) {
// ...
}
method2(/* ... */) {
// ...
}
// ...
}
class{
constructor(param1, param2, ...) {
this.property1 = param1;
this.property2 = param2;
// ...
}
method1(/* ... */) {
// ...
}
method2(/* ... */) {
// ...
}
// ...
}
class MyClass {
constructor(param1, param2, ...) {
this.property1 = param1;
this.property2 = param2;
// ...
}
method1(/* ... */) {
// ...
}
method2(/* ... */) {
// ...
}
// ...
}
class MyClass {
this.property1: param1,
this.property2: param2
// ...
method1(/* ... */) {
// ...
}
method2(/* ... */) {
// ...
}
// ...
};
Q4. Choose the correct format to declare an object:
class A{}
var a = Object.create(A);
var a = new class A{};
class A{}
var a = new A();
Q1. Choose the correct option:
Q2. Choose the correct option:
Q3. Choose the correct option:
filter()
method takes an array as a parameter and creates a new array with the results of calling a provided function on every element in this arraymap()
method offers a way to test every element of an array against a provided functionreduce()
method applies a provided function to each array element in order to reduce it to one valueQ4. Is the following statement correct?
reduce()
method takes two parameters: the first is an accumulator which contains the accumulated value previously returned by the last invocation of the function and the other parameter is the array element.
Q5. Choose the correct option:
constant
valueQ6. Choose the correct option:
let
over const
whenever applicable for variable declarationsQ1. What does the <head>
tag stores in HTML?
Q2. A Hyperlink can be in the form of:
Q3. A browser is the software you use to visit webpages and use web applications. Is this statement True or False?
Q4. What is the purpose of using JavaScript language?
Q5. Which of these could be a possible CSS Selector?
Q6. Which of the following is not an attribute of <link>
tag in HTML?
Q7. In CSS, a class is defined by using (.
) symbol and identifier is defined by using (#
) symbol. Is this statement True or False?
Q8. An HTML file is rendered by:
Q1. In HTML DOM, everything is stored in the form of:
Q2. The element <a>
is the child node of which element?
<text>
<p>
<span>
<body>
Q3. The nodes cannot be further decomposed into any more elements. Is this statement True or False?
Q4. We can access any element from document
variable in JavaScript, is this statement True of False?
Q5. The type of <p>
tag can be determined by:
p.nodeType
document.p.nodeType
p.elementType
Q6. The children of an element are stored in a childNode
property which is:
Q7. What will this statement document.parentNode
return?
Q8. The document
variable corresponds to?
<HTML>
Q1. What does querySelectorAll()
function returns?
Q2. What does the querySelector()
function returns when there is no associated element found?
Q3. The difference between querySelectorAll()
and querySelector()
is that querySelector
returns the last element, where as querySelectorAll()
returns all the elements associated to the class or identifier. Is this statement True or False?
Q4. The attributes of the following are directly accessible as properties except:
id
class
href
value
Q5. Given this HTML code:
<h1>Favourite seasons</h1>
<p>Here's the list of my favorite seasons on Netflix</p>
<div id="fav">
<ul class="seasons" id="favseasons">
<li class="netflix">Peaky Blinders</li>
<li>House of Cards</li>
<li>Narcos</li>
<li>Dexter</li>
</ul>
Can you guess what will be the output of this JavaScript this statement console.log(classes[1]);
on the code written above?
Q6. When is it convenient to use the innerHTML
property?
Q1. appendChild()
function is commonly used to add an element into the DOM structure. Is this statement True or False?
Q2. beforeend
is the position in which the element is inserted at:
Q3. How many parameters are passed in the replaceChild()
function?
Q4. Does updating DOM objects through JavaScript can affect the performance. Is this statement True or False?
Q5. The following methods could be used to modify the element in DOM except?
innerHTML()
createTextNode()
classList()
textContent()
Q6. How will we write a CSS property background-color
in JavaScript?
backGroundColor
backgroundColor
BackgroundColor
backgroundcolor
Q1. In event-driven programming, the web page reacts to user’s actions. Is this statement True or False?
Q2. What does the addEventListener()
method do?
Q3. What is the correct syntax to remove an Event Listener from the button named myButton
based on an event called "hover"
?
buttonElement.removeEventListener("hover");
myButton.removeEventListener("hover", showMessage);
buttonElement.removeEventListener("hover", showMessage);
myButton.removeEventListener("hover");
Q4. Scrolling a page by pressing the upward key from keyboard is an event which is a:
Q5. What is target in an Event object?
Q6. how many types of events are there?
Q7. Which property is used to fetch the code of a key when it is pressed?
charInfo
keyInfo
charCode
keyCode
Q8. Which method()
is used to retrieve the mouse click?
getMouseInfo()
getMouseClick()
getMouseButton()
Q9. What is event propagation?
Q10. Event triggered on child node get triggered on the child node only
unload
scroll
select
copy
Q1. A ______ lets users input data through a web page
<form>
<button>
<input>
Q2. We access the content of inputs via this property:
Q3. We access the content of inputs via this property:
Q4. Which event gets triggered when the user modifies an input?
Q5. Regular experessions can be used to validate the data in JavaScript. Is this statement True or False?
Q6. When we submit the form, which of the following events get triggered?
onformSubmit
submit
validate
Q7. When do we use preventDeafult()
method?
Q8. Which of the following is not the attribute of <input>
Q1. Which of the following method triggers a repeated action?
clearInterval()
setTimeOut()
setInterval()
Q2. Which of the following method stops a repeated action?
setInterval()
clearInterval()
setTimeOut()
Number()
Q3. Which function is used to execute a function after a certain delay?
setInterval()
setTimeOut()
clearInterval()
Q4. The requestAnimationFrame()
function asks the browser to execute a function that updates the animation as soon as possible. Is this statement True or False?
Q5. You cannot create animations via CSS. Is this statement True or False?
Q6. The cancelAnimationFrame()
function stops an in-progress animation that was launched with requestAnimationFrame()
, is this statement True or False?
Q1. Data exchanges on the Web follow a _______ paradigm.
Q2. The secured version of HTTP is:
Q3. HTTP is the protocol that allows two machines to communicate with each other on the web.
Q4. Which of the following is not an HTTP method?
Q5. Which method is used when we want to send data to the server?
Q6. The status code for success is:
Q7. AJAX supports synchronous web requests. Is this statement True or False?
Q8. Cross-domain AJAX requests are not possible if the server has been configured to accept them by setting on cross-origin resource sharing. Is this statement True or False?
Q9. Which data representing format is better:
Q10. Status codes in the form of 5xx are:
Q1. HTTP requests sent to a web server need to be synchronous to prevent blocking the client application while waiting for the server’s response.
Q2. The XMLHttpRequest()
method is better than fetch()
method as the go-to way of creating an asynchronous request.
Q3. Which of the following could not be a possible state for promise?
Q4. When is catch()
method called in JavaScript?
Q5. The difference between XMLHttpRequest
and fetch()
is that XMLHttpRequest
uses promises. Is this statement True or False?
Q6. Which of the following method is used to convert JSON data into valuable objects?
fetch()
parse()
then()
stringify()
Q1. What do we use APIs for?
Q2. Document Object Model itself is an API. Is this statement True or False?
Q3. Web Services do not provide an interface for web applications. Is this statement True or False?
Q4. Which of the following real-world example demonstrates best the use of web API?
Q5. The data recieved via API is in the what form?
Q6. The access key is used to authorize a user. Is this statement True or False?
Q1. Which object is used to send form data to the server?
Response
JSONData
FormData
POST
Q2. Which function is used to fill the FormData
object with values?
fill()
addElement()
append()
Q3. When the information expected by the server is more structured, which data format is more convenient to use?
Q4. The second parameter of the fetch()
call sets the suitable HTTP method to send the response back to server. Is this statement True or False?
Q5. By default, the form submits the data asynchronously. Is this statement True or False?
Q1. Node.js focuses more on:
Q2. Node.js offers which method to laod a module?
loadModule()
runModule()
require()
module()
Q3. Inside a module, which object is used to export an element?
Q4. We can not reassign module.export
to export only a specific element, is it correct?
Q5. Which file is the set the default entry point of a Node package?
package.json
default.json
index.json
Q6. A semantic versioning format is a ______ digit format used to define package versions.
Q7. In semantic versioning format, the string is in the form:
Q8. Once installed through npm
, packages defined as dependencies are stored in the
node_modules/packages
node_modules/subfolder
node_module/dependencies
node_module/subfolder/packages
Q9. The packages containing only executable files or no entry point can be loaded as modules, is this statement True or False?
Q1. The Node.js platform is not quite suited for creating web servers in JavaScript. Is this statement True or False?
Q2. A ______ provides a standard way to design and structure an application
Q3. The entry point associated to URLs defined by an Express app is called:
Q4. What does the term middleware mean?
Q5. Which package is used to manage the JSON data or an incoming form?
Q6. JavaScript can only be used on the server side of a web application. Is this statement True or False?
I hope this Complete JavaScript Course: Build a Real World App from Scratch Educative Quiz Answers would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coding Solutions.
This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.
Keep Learning!
More Coding Solutions >>