JavaScript Course | Practice Quiz-3 Read Discuss Courses JavaScript Course Quiz 3 Please wait while the activity loads. If this activity does not load, try refreshing your browser. Also, this page requires javascript. Please visit using a browser with javascript enabled. If loading fails, click here to try again Question 1 What will be the output of the following code? JavaScript <script> let result = 0; for (let i = 0; i < 5; i++) { result += i; } document.write(result); </script> 5 0 10 None of the above JavaScript Course Quiz 3 Discuss itQuestion 1-Explanation: The loop will run from 0 to 4, thus adding 0+1+2+3+4 = 10. So, the answer will be 10. Question 2True or false: All keys in an object are strings.TrueFalseDepends on the Object typeNone of the aboveJavaScript Course Quiz 3 Discuss itQuestion 2-Explanation: keys can only be strings, and numeric keys such as those used in Arrays are coerced and stored as strings.Question 3Given a collection of artists and lists of their songs, would you store the artist-song-list pairs in an Object or an Array?ObjectArrayFunctionNone of the aboveJavaScript Course Quiz 3 Discuss itQuestion 3-Explanation: If you want to store a bunch of numbers or a list of objects of the same type, use an array. But here we have to store list of their strongs as per their name so we will use Object.Question 4What will be the output of the following code? <script> if (5) { document.write("I like peanuts"); } </script> I like peanutsundefinednothing will be printedNone of the aboveJavaScript Course Quiz 3 Discuss itQuestion 4-Explanation: In Javascript, Any natural number other than 0 is taken as true, therefore "I like peanuts" will be printed.Question 5What will be the output of the following code? <script> let bar = 1; foo = {}; foo: { bar : 2; baz : ++bar; }; document.write(foo.baz + foo.bar + bar); </script> NaN541JavaScript Course Quiz 3 Discuss itQuestion 5-Explanation: It's not actually altering the variable foo. Here the text foo is part of a label, and the object that follows is called a javascript block and it contains two labeled statements, not variable assignments. That leaves us with two undefined variables added to 1. Which is NaN. If the variable bar was not declared higher in the code this object would kick out a syntax error as bar would be undefined.Question 6 What will be the output of the following code? < script> document.write( 10 > 9 > 8 === true ); </ script> true false 1 0 JavaScript Course Quiz 3 Discuss itQuestion 6-Explanation: As humans we read the above something like, "ten is greater than 9 which is greater than 8", or: (10 > 9) && (9>8) Javascript, however, is beholden to its order of operations implementation. Which causes the line to be evaluated as: ((10>9)>8) or (true>8) or (1>8) which is false. Question 7What will be the output of the following code? <script> document.write(String('Hello') == 'Hello'); </script> truefalse10JavaScript Course Quiz 3 Discuss itQuestion 7-Explanation: They are equal because both of them are strings.Question 8What will be the output of the following code? <script> document.write(( true + false ) > 2 + true ); </script> truefalse10JavaScript Course Quiz 3 Discuss itQuestion 8-Explanation: Here, True will change to 1, and False to 0. Hence, (1+0)>(2+1) => 1>3 is False.Question 9What will be the output of the following code? <script> document.write(Number('1') - 1 == 0); </script> truefalse1None of the aboveJavaScript Course Quiz 3 Discuss itQuestion 9-Explanation: You're casting the string 1 as a number, and subtracting it from the number 1. This equals 0.Question 10What will be the output of the following code? <script> document.write(NaN == NaN); </script> truefalse10JavaScript Course Quiz 3 Discuss itQuestion 10-Explanation: Equality operator (== and ===) cannot be used to test a value against NaN. Use Number.isNaN() or isNaN() instead. Hence, it is not equal. 1 There are 10 questions to complete. You have completed questions question Your accuracy is Correct Wrong Partial-Credit You have not finished your quiz. If you leave this page, your progress will be lost. Correct Answer You Selected Not Attempted Final Score on Quiz Attempted Questions Correct Attempted Questions Wrong Questions Not Attempted Total Questions on Quiz Question Details Results Date Score Hint Time allowed minutes seconds Time used Answer Choice(s) Selected Question Text All doneNeed more practice!Keep trying!Not bad!Good work!Perfect! Last Updated : 27 Sep, 2023