JS Input/Output Solution 2

Is this statement correct? If yes, what will be the output here?

1
2
3
let bob = a => a + 100;

console.log(bob(2)); //?

Solution:

Yes, this statement is correct.

1
2
3
let bob = a => a + 100;

console.log(bob(2)); //102

It is a shorthand syntax of arrow function to write a single line function. You can write this also:

1
2
3
4
5
let bob = (a) => {
    return a + 100
};

console.log(bob(2)); //102