QUIZ
Q1: What is the final value of "obj" in the following example?
const obj = { foo: 1 };
obj.bar = 2;
Ans: {foo: 1,bar:2}
Q2: What will be the output ?
function min(nums){
return Math.min(nums)
}
console.log(min( [1,3,2 ]))
Ans: NaN
Q3: What will be the output?
const cube=x=> x*x*x;
console.log(cube(2))
Ans: 8
Q4: What would be the output ?
const [a, b] = [1,2,3,4,45,5];
console.log(a+b);
Ans: 3
Q5: What will the filter method return?
Ans: An array containing all the matching elements
Q6: What will be the value of y?
const {x, y, z} = {x: 1, y1: 2, z: 3};
Ans: undefined
Q7: What will be the output?(Try it out. It’s tricky.)
const nums = [1,2,3,4,5];
let output = nums.filter(n => n%2);
console.log(output);
Ans: [1,3,5]
Q8: How will you find the first friend who has a name with 5 characters?
const friends = ["Moushumi", "Misha", "Manna", "mimi" , "mahiya"];;
Ans: friend.find(friend => friend.length == 5);
Q9: How will you get the price from the product object?
const product = {name: 'Laptop', model:'Yoga 3', price:49000, dusk: '512SSD'}
You have selected "const {price} = product.price;" but correct answer is "const {price} = product;".
Ans: const{price} = products;
Q10:How will you create an instance of Person Class ?
Ans: const student = new Person()