DEV Community

Discussion on: 70 JavaScript Interview Questions

Collapse
 
droutback profile image
DrOutback

โ€œlet x = 5;

x = (x++ , x = addFive(x), x *= 2, x -= 5, x += 10);

function addFive(num) {
return num + 5;
}
If you log the value of x it would be 27. First, we increment the value of x it would be 6, then we invoke the function incrementBy5(6) and pass the 6 as a parameterโ€

Do you mean addFive(6)?

Iโ€™m new to js, so Iโ€™m probably wrong.

Collapse
 
macmacky profile image
Mark Abeto

Thanks for telling me this little problem ๐Ÿ˜

Collapse
 
droutback profile image
DrOutback

Thanks for writing the article. Iโ€™m enjoying it.

Also,

reduce.apply(obj1, [1, 2, 3, 4, 5]); // returns 15
reduce.apply(obj2, 1, 2, 3, 4, 5); // returns 15

Did you mean reduce.call obj2, 1, 2, 3, 4, 5); ?

Thread Thread
 
macmacky profile image
Mark Abeto

Thanks again ๐Ÿ˜