90% failed to answer these tricky javascript snippets
Jan 9, 2023
Q1. Guess the output
var x=0
x++
x=’vineet’
x=true
console.log(`Value of x ${x} ,\n type of x ${typeof(x)}`)
Take a breath, Don’t jump into solution
Output:
Value of x true ,
type of x boolean
Q2. Guess the output
const compact = arr => console.log(arr.filter(Boolean));
compact([0, 1, false, 2, ‘’, 3, ‘a’, ‘e’ * 23, NaN, ‘s’, 34])
Take a breath, Don’t jump into solution
Output:
[ 1, 2, 3, 'a', 's', 34 ]