90 % Fail To answer theses JavaScript snippets

Q1. Guess the output

console.log(0.1 + 0.2);

console.log(0.1 + 0.2 == 0.3);

Take a breath, don’t jump directly into solution


Reason: In this snippet , first one is very straight forward, its the addition of 2 decimal numbers values in the next one , we are testing condition that is true or false

Q2. Guess the output

function getValue1() {

return {

bar: “hello” };


function getValue2() {



bar: “hello”



console.log(“getValue1 returns:”); 
console.log(“getValue2 returns:”);

Wait will this snippet run fine? think hard , don’t jump into solution

getValue1 returns:
{ bar: 'hello' }
getValue2 returns:

Reason: The reason for this has to do with the fact that semicolons are technically optional in JavaScript (although omitting them is generally really bad form). As a result, when the line containing the return statement (with nothing else on the line) is encountered in getValue2(), a semicolon is automatically inserted immediately after the return statement.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Vineet Mishra

Vineet Mishra

Full Stack Developer at CCR Tech, I write about Mobile/Web Development and Deployment, and Interview Q & A