Closed
Description
Here are some new questions that I discovered when taking the JavaScript assessment. I wasn't confident in my answers, so maybe someone else can chime-in.
### Q1. Which statement prints "roar" to the console?
var sound "grunt";
var bear = { sound: "roar"};
function roar){
console.log(this.sound);
- [ ] bear.bind(roar);
- [ ] roar.bind(bear);
- [ ] roar.apply(bear);
- [ ] bear[roar]();
### Q2. Which line could you add to this code to print "jaguar" to the console?
let animals = ["jaguar","eagle"];
//Missing Line
console.log(animals.pop()); //Prints jaguar
- [ ] `animals.filter(e => e === "jaguar");`
- [ ] `animals.reverse();`
- [ ] `animals.shift();`
- [x] `animals.pop();`
### Q3. Which snippet could you add to this code to print "food" to the console?
class Animal {
static belly = [];
eat () { Animal.belly.push("food"); }
let a = new Animal();
a.eat();
console.log(/* Snippet Here */); //Prints food
- [ ] `a.prototype.belly[0]`
- [ ] `Object.getPrototype0f (a).belly[0]`
- [ ] `Animal.belly[0]`
- [ ] `a.belly[0]`