Question #49

Author: admin
tags: JavaScript  
Take your time, look at the code carefully:
let getWeaponObj = () => { weaponRounds: 5 };
let additionalRounds = '1';
let fullRounds = additionalRounds + getWeaponObj().weaponRounds;

console.log(fullRounds); // ??
What will the console output be?
1
5
6
'15' (string)
'51' (string)
NaN
Nothing. There will be an error.
It's all about the syntax of the arrow function.
In this case, the arrow function does not return an object, curly braces are the body of the arrow function, and weaponRounds is not the name of the object property, but is the label of the code block (labeled statement).
The function doesn't return anything explicit, so it returns undefined, and undefined doesn't have the weaponRounds property, so a TypeError occurs.
Rate the difficulty of the question:
easyhard