You have a request ? Contact Us Join Us

Programming with JavaScript

Coursera: Meta React Native Specialization. Module quiz: Introduction to JavaScript, The Building Blocks of a Program, Programming Paradigms, Testing
Programming with JavaScript


Module quiz: Introduction to JavaScript 

1. You can run JavaScript in a web browser's devtools console.
  • true
  • false
2. Which of the following are valid comments in JavaScript? Select all that apply.
  • \ Comment 1
  • // Comment 2
  • ##
    ## Comment 3
    ##
  • /*
     * Comment 4
     */
3. Which of the following are valid data types in JavaScript? Select all that apply.
  • string
  • numbers
  • booleans
  • null
4. Which of the following is the logical AND operator in JavaScript?
  • &
  • &&
  • ||
  • |\
5. Which of the following is the assignment operator in JavaScript?
  • =
  • ==
  • ===
6. How many times will the following code print the word 'Hello'?
  for(var i = 0; i <= 5; i++) {
    console.log("Hello");
  }
  • 4
  • 5
  • 6
7. What will print out when the following code runs?
  var i = 3;
  var j = 5;
  if(i == 3 && j < 5) {
    console.log("Hello");
  } else {
    console.log("Goodbye");
  }
  • Hello
  • Goodbye
  • Nothing
8. What will print out when the following code runs?
  var i = 7;
  var j = 2;
 
  if(i < 7 || j < 5) {
    console.log("Hello");
  } else {
    console.log("Goodbye");
  }
  • Hello
  • Goodbye
  • Nothing
9. The result of !false is:
  • true
  • undefined
10. What does the operator symbol || represent in JavaScript?
  • The logical NOT operator
  • The logical OR operator
  • The logical AND operator

Module quiz: The Building Blocks of a Program

1. What data type is the variable  x ?
  var x = {};
  • Function
  • Array
  • Object
2. What will be the output of running the following code?  
try {
console.log('hello)
} catch(e) {
console.log('caught')
}
  • Uncaught SyntaxError: Invalid or unexpected token.
  • Caught
3. What value is printed when the following code runs?
  var burger = ["bun", "beef", "lettuce", "tomato sauce", "onion", "bun"];
  console.log(burger[2]);
  • bun
  • beef
  • lettuce
  • tomato sauce
  • onion
4. In the following code, how many methods does the  bicycle  object have?
  var bicycle = {
      wheels: 2,
      start: function() {
 
      },
      stop: function() {
 
      }
  };
  • 1
  • 2
  • 3
5. When the following code runs, what will print out?
  try {
    throw new Error();
    console.log('Hello');
  } catch(err) {
    console.log('Goodbye');
  }
  • Hello
  • Goodbye
6. If you mis type some code in your JavaScript, what kind of error will that result in?
  • RangeError
  • SyntaxErrror
  • TypeError
7. Will the following code execute without an error?
  function add(a, b) {
    console.log(a + b)
  }
  add(3, "4");
  • Yes
  • No
8. What will be printed when the following code runs?
  var result;
  console.log(result);
  • undefined
  • null
  • 0
9. What will be the output of the following code?
var str = "Hello";
str.match("jello");
  • null
  • undefined
  • empty string
10. What will be the output of the following code?
try {
Number(5).toPrecision(300)
} catch(e) {
console.log("There was an error")
}
  • RangeError
  • 5
  • e
  • "There was an error"

Module quiz: Programming Paradigms

1. Variables declared using  'let' can be reassigned.
  • true
  • false
2. What will print out when the following code runs?
    function scopeTest() {
        var y = 44;
        console.log(x);
    }
    var x = 33;
    scopeTest();
  • null
  • undefined
  • 33
  • 44
3. What will print out when the following code runs?
    class Cake {
        constructor(lyr) {
            this.layers = lyr;
        }
        getLayers() {
            return this.layers;
        }
    }
    class WeddingCake extends Cake {
        constructor() {
            super(2);
        }
        getLayers() {
            return super.getLayers() * 5;
        }
    }
    var result = new WeddingCake();
    console.log(result.getLayers());
  • 0
  • 2
  • 5
  • 10
4. What will print out when the following code runs?
    class Animal {
 
    }
 
    class Dog extends Animal {
        constructor() {
            super();
            this.noise = "bark";
        }
 
        makeNoise() {
          return this.noise;
        }
    }
 
    class Wolf extends Dog {
        constructor() {
            super();
            this.noise = "growl";
        }
    }
 
    var result = new Wolf();
    console.log(result.makeNoise());
  • bark
  • growl
  • undefined
5. Consider this code snippet: 'const  [a, b]  =  [1,2,3,4] '. What is the value of  b?
  • undefined
  • 1
  • 2
  • [1,2,3,4]
6. What value will be printed out when the following code runs?
    function count(...food) {
        console.log(food.length)
    }
    count("Burgers", "Fries", null);
  • 2
  • 3
  • "Burgers", "Fries", null
  • "Burgers", "Fries", undefined
7. Which of the following are JavaScript methods for querying the Document Object Model? Select all that apply.
  • getElementsByClassName
  • getElementsById
  • getElementById
  • getElementByClassName
  • queryAllSelectors
  • querySelector
8. Which of the following methods convert a JavaScript object to and from a JSON string?
  • JSON.parse
  • JSON.stringify
  • JSON.fromString
  • JSON.toString
9. What will be the result of running this code?  
const letter = "a"
letter = "b"
  • Uncaught TypeError: Assignment to constant variable   
  • b
  • a
  • Uncaught SyntaxError: Invalid or unexpected token
10. What is a constructor?
  • A function that is called to create an instance of an object.  
  • An instance of a class.
  • A specific object that has been created using the class name.
  • An object literal  

Module quiz: Testing

1. Which of the following is a framework that can help you run a unit test?
  • JFrame
  • Jest
  • JavaTest
  • JavaFrame
2. When the following test executes, what will the test result be?
function subtract(a, b) { 
      return a   b; 
     } 
 expect(subtract(10, 4)).toBe(6); 
  • Success.
  • Fail.
3. True or False: End to end testing is the slowest and most expensive type of testing.
  • True.
  • False
4. What reason would you want to know about your code coverage?
  • It lets you know where more testing may be required.
  • It lets you know if you are done writing code.
  • It lets you know if you are testing correctly.
  • It lets you know if your code is in Javascript.
5. The development of Node.js led to the ability to do which of the following?
  • Run unit tests
  • Estimate code coverage
  • Download and manage packages
  • Write full stack JavaScript programs.
6. Which of the following are NOT one of the three types of testing?
  • Integration testing
  • End to end testing
  • Post hoc testing
  • Unit testing
7. True or False: You can install packages from the npm repository using the node command.
  • True
  • False
8. Which file lists all your application's required node packages?
  • node.json
  • pkg.json
  • npm.json
  • package.json
9. Which of the following statements are NOT benefits of using Test Driven Development or TDD?
  • Minimizing regressions like accidental bugs introduced to old code.
  • You have proof that your new implementation is not breaking other parts of the app.
  • You can automate these tests easily and thus keep verifying again and again that the system works as expected.
  • You can run tests without setting them up.
10. Which of the below statements would NOT be a benefit of Mocking?
  • You can test the front end functionality of your web app by mocking the data as if it came back from a server.
  • Mocks, allow you to pretend that users are already there if the backend hasn't been built yet.
  • Mocking is a substitute for testing.
  • Mocking allows you to separate the code that you are testing from its related dependencies.

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.