Calculate the execution order of:
(_.sum
takes an array and sums all the numbers in the array e.g. _.sum([1,2,3]) === 6
)
_.sum([1, 1 + 2, 0, [1, 2, 3].length])
Answer:
_.sum([1, 1 + 2, 0, [1, 2, 3].length])
_.sum([1, 3, 0, [1, 2, 3].length])
_.sum([1, 3, 0, 3])
7
If you get stuck. Use the Chrome console to run the code and test things out.
Calculate the execution order of:
[1, 2, 3, 4 + 5].length
Calculate the execution order of:
'hello'.substring(0, 3).length
Calculate the execution order of:
'hello'.substring(0, 3 - 1).length + 'world'
Calculate the execution order of:
{
hello: 'wor' + 'ld'
}
Here are the answers to the questions. Try your best to do it on your own! If you have questions - ask on Discord.