Skip to content

Latest commit

 

History

History
32 lines (22 loc) · 679 Bytes

File metadata and controls

32 lines (22 loc) · 679 Bytes

Code comprehension

Remember to preview a markdown file on your computer you can do: Ctrl + Shift + V (Windows/Linux) or CMD + Shift + V (Mac)

Consider the code in this program below:

function calculateSum(a, b) {
  return a + b;
}

function logSum(a, b) {
  console.log(a + b);
}

const result1 = calculateSum(10, 32);
const result2 = logSum(10, 32);

a) what will result1 evaluate to? Explain your answer

b) What will result2 evaluate to? Explain your answer

c) Try to summarise the main difference between logSum and calculateSum

{ result1: 10 + 32 result2: 42 main difference: logSum uses parentheses, so it calculate the total of the numbers }