All Coursera Quiz Answers

Final graded quiz: Programming with JavaScript Quiz Answers

In this article i am gone to share Coursera Course: Programming with JavaScript Week 5 |ย  Final graded quiz: Programming with JavaScript Quiz Answers with you..

Programming with JavaScript Coursera Quiz Answers

Enroll Link: Programming with JavaScript


Also visit: Module quiz: Testing Quiz Answers


 

Final graded quiz: Programming with JavaScript Quiz Answers

Question 1)
What will be the output of the following JavaScript?

const a = 10;
const b = 5;
if(a == 7 || b == 5) {
console.log("Green");
} else {
console.log("Blue");
}
  • Green
  • Blue
  • Nothing

Question 2)
What will be the output of the following JavaScript?

var message = "Hello";
message += " World!";
message = "Goodbye!";
console.log(message);
  • Hello
  • World!
  • Hello World!
  • Goodbye!

Question 3)
What is the data type of the x variable in the following code?

var x = 23.2;
  • Number
  • BigInt
  • String
  • Boolean

Question 4)
What will the following JavaScript code output?

var x = 10;
if(x > 10) {
console.log("Apple");
} else if(x > 5) {
console.log("Pear");
} else {
console.log("Orange");
}
  • Apple
  • Pear
  • Orange

Question 5)
What will the following JavaScript code output?

var result = 0;
for(var i = 0; i < 5; i++) {
result += 2;
}
console.log(result);
  • 0
  • 2
  • 5
  • 10

Question 6)
When the following code runs, what will print out?

try {
throw new Error();
console.log('Square');
} catch(err) {
console.log('Circle');
}
  • Square
  • Circle

Question 7)
What’s missing from this JavaScript function declaration?

function(a,b) {
return a + b
}
  • The function name.
  • The assignment operator.
  • The dot notation.

Question 8)
What is the output of the code below?

var cat = {}
cat["sound"] = "meow"
var catSound = "purr"
console.log(cat.sound)
  • meow
  • purr
  • {}
  • catSound

Question 9)
What is the output of the code below?

var veggies = []
veggies.push('parsley')
veggies.push('carrot')
console.log(veggies[2])
  • undefined
  • 2
  • 1
  • 3

Question 10)
True or False. The second argument passed to the addEventListener function is the actual function that will handle the event, when it gets triggered.

  • True
  • False

Question 11)
What does this line of code do?

document.createElement('h2').innerText = "Heading Level 2"
  • It creates an h2 element without adding it to the page.
  • This syntax is invalid.
  • It adds an inner-text HTML attribute to the h2 element.

Question 12)
Is the code below missing a .js after the ./addFive ?

const addFive = require('./addFive')
  • true
  • false

 

Question 13)
What will be the output of the following JavaScript?

const a = true;
if(!a) {
console.log("Green");
} else {
console.log("Blue");
}
  • Green
  • Blue
  • Nothing

Question 14)
What will be the output of the following JavaScript?

var x = 2;
x += 5;
console.log(x);
  • 2
  • 3
  • 5
  • 7

Question 15)
What is the data type of the x variable in the following code?

var x = "Hello";
  • Number
  • BigInt
  • String
  • Boolean

Question 16)
What will the following JavaScript code output?

var x = 20;
if(x < 5) {
console.log("Apple");
} else if(x > 10 && x < 20) {
console.log("Pear");
} else {
console.log("Orange");
}
  • Apple
  • Pear
  • Orange

Question 17)
What will the following JavaScript code output?

var result = 0;
var i = 4;
while(i > 0) {
result += 2;
i--;
}
console.log(result);
  • 0
  • 2
  • 4
  • 8

Question 18)
What will the following JavaScript code output?

console.log(result);
var result = 7;
  • null
  • undefined
  • 7

Question 19)
What will be the result of running the following JavaScript code snippet?

function addTwo(a,b) {
return a
}
addTwo(5,10)
  • 5
  • 10
  • undefined

Question 20)
What is the output of the code below?

var cat = {}
cat.sound = "meow"
var catSound = "purr"
console.log(cat.sound)
  • meow
  • purr
  • {}
  • catSound

Question 21)
What is the output of the code below?

var veggies = ['parsley', 'carrot']
console.log(veggies[2])
  • undefined
  • 2
  • 1
  • 3

Question 22)
Which of the following HTML attributes is used to handle a click event?

  • onclick
  • addEventListener(‘click’)
  • ‘click’

Question 23)
How can you add an HTML attribute to an HTML element using JavaScript?

  • By invoking the setAttribute method on a given element.
  • By invoking the getAttribute method on a given element.
  • By invoking the createAttribute method on a given element.

Question 24)
What does this code do?

function addFive(val){ 
return val + 5;
};

module.exports = addFive;
  • It defines the addFive function and exports it as a Node module so that it can be used in other files.
  • This syntax is invalid.
  • It allows you to invoke the addFive function without the parentheses.

Question 25)
What will be the output of the following JavaScript?

var x = true;
x = 23;
console.log(x);
  • true
  • 23

Question 26)
What will the following JavaScript code output?

var x = 20;
if(x >= 10) {
console.log("Apple");
} else if(x <= 5) {
console.log("Pear");
} else {
console.log("Orange");
}
  • Apple
  • Pear
  • Orange