Skip to content
The Chat Archive
gpt-4o-2024-05-13· OpenAI WildChat-4.8M (AI2)

The querySelector() method returns the first element that matches a specified CSS…

  1. User

    The querySelector() method returns the first element that matches a specified CSS selector(s) in the document.

    Group of answer choices

    True

    False

    Flag question: Question 2 Question 26.9 pts _________ event handler invokes when the mouse clicks on an element. Group of answer choices

    onmouseover

    onclick

    onmouseleave

    onmousedown

    Flag question: Question 3 Question 36.9 pts Modern JavaScript is a “safe” programming language. It does not provide low-level access to memory or CPU, because it was initially created for browsers which do not require it.

    True or False?

    Group of answer choices

    True

    False

    Flag question: Question 4 Question 46.9 pts We can use the ___________ method of the Document object, which returns a collection of all elements in the document with the specified tag name as a NodeList object Group of answer choices

    getElementsByTagName()

    getElementsByID()

    getElementsByHtml()

    getElementsByClass()

    Flag question: Question 5 Question 56.9 pts What is the console output of the following JavaScript code?

    let arr = [1, 2, 3, 4, 5, ]; arr.forEach(function(value, index, array) { array[index] = value * value }); console.log(arr.reverse().filter(function(x) { return x % 5 })); Group of answer choices

    [16, 9, 4, 1]

    [25, 16, 9, 4, 1]

    [4, 3, 2, 1]

    Error

    Flag question: Question 6 Question 66.9 pts What is the console output of the following JavaScript code?

    let a = "Per Scholas";

    let x = a.lastIndexOf("l"); console.log(x); Group of answer choices

    7

    8

    6

    Error

    Flag question: Question 7 Question 76.9 pts What is the console output of the following JavaScript code? let a = "Per Scholas"; let result = a.substring(4, 5);

    console.log(result); Group of answer choices

    M

    Me

    s

    S

    Flag question: Question 8 Question 86.9 pts What is the console output of the following JavaScript code?

    let date = new Date("Thu Jan 29 2009 17:31:44"); let now = new Date("2019-01-24 18:31:44");

    console.log(now.getMonth() === date.getMonth()); Group of answer choices

    True

    False

    1

    Jan

    Flag question: Question 9 Question 96.9 pts What is the console output of the following JavaScript code?

    let person = { firstName: "John", lastName: "Doe", age: 50, eyeColor: "blue" };

    for (let i in person) { console.log(i); } Group of answer choices

    "firstName" "lastName" "age" "eyeColor"

    "John" "Doe" 50 "blue"

    undefined undefined undefined undefined

    Flag question: Question 10 Question 106.9 pts What are 2 ways of registering an event listener? (Select all that apply) Group of answer choices

    Using an inline event handler like onClick="myEventListener()"

    Add an button listener to the html tag

    use "addEventListener" to register the event handler

    Add prototypes using HTML tag

    Flag question: Question 11 Question 116.9 pts What is the console output of the following JavaScript code?

    console.log("Hello" - " World");

    Group of answer choices

    NaN

    "Hello" + " World"

    Error

    Hello World

    Flag question: Question 12 Question 126.9 pts What is the correct syntax for adding comments in JavaScript? Group of answer choices

    //This is a comment

    <!–This is a comment–&gt

    –This is a comment

    This is a comment

    Flag question: Question 13 Question 136.9 pts What is one difference between the Array.slice() and the Array.splice() methods in JavaScript? Group of answer choices

    The Array.splice() changes the original array whereas Array.slice() does not

    The Array.slice() changes the original array whereas Array.splice() does not .

    The Array.slice() returns all elements of the array starting at the indicated index until the end of the array, whereas the Array.splice() returns all elements of the array starting at the beginning of the array until the indicated index.

    The Array.splice() returns all elements of the array starting at the indicated index until the end of the array, whereas the Array.slice() returns all elements of the array starting at the beginning of the array until the indicated index.

    Flag question: Question 14 Question 146.9 pts What does a number data type represent in JavaScript? Group of answer choices

    integers and floats

    integers only

    floats only

    none of the mentioned

    Flag question: Question 15 Question 156.9 pts Which function of an Array object calls a function for every element in the array? Group of answer choices

    forEach()

    forEvery()

    callForEach()

    callForEvery

    Flag question: Question 16 Question 166.9 pts What is the console output of the following JavaScript code?

    var name = "Per Scholas"; var name = "JavaScript";

    console.log(name); Group of answer choices

    JavaScript

    Per Scholas

    Error

    name

    Flag question: Question 17 Question 176.9 pts What is the console output of the following JavaScript code?

    let name = "Per Scholas"; let name = "JavaScript";

    console.log(name); Group of answer choices

    Error

    Per Scholas

    JavaScript

    name

    Flag question: Question 18 Question 186.9 pts What is the console output of the following JavaScript code?

    a = 8 + "8"; console.log(a); Group of answer choices

    88

    Run Time Error

    Compilation Error

    16

    Flag question: Question 19 Question 196.9 pts What is the console output of the following JavaScript code?

    numbers = "12345"; for (let i = 0; i < 5; i++) { if (numbers[i] == 3) { continue; } console.log(numbers[i]); } Group of answer choices

    1 2 4 5

    1 2

    1 2 3 4 5

    5

    Flag question: Question 20 Question 206.9 pts What is JavaScript?

    In Strongly typed languages once a type is assigned to a variable - say at run time or compile time, it retains that type and can’t be intermingled in expressions with other types easily.

    In Weakly typed languages, once a type is assigned to a variable - say at run-time or compile-time, it can be intermingled in expressions with other types easily.

    Group of answer choices

    A high-level and weakly typed scripting programming language

    A high-level and strongly typed compiled programming language

    A low-level and strongly typed compiled programming language

    A low-level and weakly typed compiled programming language

    Flag question: Question 21 Question 216.9 pts What is the console output of the following JavaScript code?

    console.log("Hello" + " World");

    Group of answer choices

    Hello World

    NaN

    "Hello" + " World"

    Error

    Flag question: Question 22 Question 226.9 pts What is the console output of the following JavaScript code?

    numbers = "12345"; for (let i = 0; i < 5; i++) { if (numbers[i] == 3) { break; } console.log(numbers[i]); } Group of answer choices

    1 2

    1 2 4 5

    1 2 3 4 5

    5

    Flag question: Question 23 Question 236.9 pts In a dynamic Web app, elements and text are often added with JavaScript. The _______ and _______ methods are used to create new nodes or elements and content in the DOM. (Select all that apply) Group of answer choices

    createElement()

    new Paragraph()

    doument.Element()

    createTextNode()

    Flag question: Question 24 Question 246.9 pts What will be the result of the following statement in Javascript? (True / False)

    8 === "8"

    Group of answer choices

    True

    False

    Flag question: Question 25 Question 256.9 pts What is the correct syntax for referring to an external script called “script.js”? Group of answer choices

  2. Assistant

    Sure, here are the correct answers to your quiz:

    1. True
      The querySelector() method indeed returns the first element that matches a specified CSS selector(s) in the document.

    2. onclick
      The onclick event handler is invoked when the mouse clicks on an element.

    3. True
      Modern JavaScript is a "safe" programming language as it does not provide low-level access to memory or CPU.

    4. getElementsByTagName()
      The getElementsByTagName() method returns a collection of all elements in the document with the specified tag name as a NodeList object.

    5. [16, 9, 4, 1]
      After squaring and reversing the array, and then filtering out numbers that are not multiples of 5, [25, 16, 9, 4, 1] transforms to [16, 9, 4, 1].

    6. 8
      a.lastIndexOf("l") returns 8 because the last occurrence of "l" in "Per Scholas" is at index 8.

    7. S
      a.substring(4, 5) would return the character at index 4, which is "S".

    8. False
      The getMonth() method returns a zero-based number (January is 0), and January 29 is different from January 24, even though they are both in January.

    9. "firstName" "lastName" "age" "eyeColor"
      When using for...in to iterate over an object, it lists the keys of the object.

    10. Using an inline event handler like onClick="myEventListener()" and use "addEventListener" to register the event handler
      These are standard ways of registering event listeners in JavaScript.

    11. NaN
      Subtracting two strings in JavaScript results in NaN.

    12. //This is a comment
      This is the correct syntax for single-line comments in JavaScript.

    13. The Array.splice() changes the original array whereas Array.slice() does not
      Use splice to add/remove elements which changes the array, and use slice to get a subarray without modifying the original array.

    14. integers and floats
      JavaScript's number type can represent both integers and floating-point numbers.

    15. forEach()
      The forEach() method of an array calls a provided function once for each element in the array.

    16. JavaScript
      Declaring a variable multiple times with var will not cause an error, and the last assignment wins.

    17. Error
      Using let to declare the same variable name in the same scope will result in a syntax error.

    18. 88
      JavaScript will concatenate the number 8 and the string "8", resulting in the string "88".

    19. 1 2 4 5
      Using continue will skip the iteration where i equals 3 and all other elements will be printed.

    20. A high-level and weakly typed scripting programming language
      JavaScript is high-level and weakly typed, allowing flexible type assignments.

    21. Hello World
      Concatenating two strings using the + operator results in "Hello World".

    22. 1 2
      The loop breaks when the condition numbers[i] == 3 is met, so only 1 and 2 are printed.

    23. createElement() and createTextNode()
      These methods are used to create new nodes or elements and content in the DOM.

    24. False
      The === operator checks for both value and type, and 8 (number) is not equal to "8" (string).


    25. This is the correct way to refer to an external script file.

    26. alert("Hello JS!");
      This is the correct syntax to display an alert box.

    27. console.log(i!=5);
      This simple condition directly checks if i is not equal to 5.

    28. "x*y"
      Since the expression is inside quotes, res will be a string containing "x*y".

    29. False
      An external JavaScript file should not contain HTML tags.