Skip to content

Latest commit

 

History

History
35 lines (22 loc) · 931 Bytes

0.md

File metadata and controls

35 lines (22 loc) · 931 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

The function calculateSum takes two arguments and returns the value of those arguments added together (summed)

a) the sum of the two parameters is stored in result1 evaluate to 42

b) result2 will log out the sum but doesn't return a value - we're not sure what it will return undefined

c) Summarise the main differences : 1 returns a sum, 2 writes to the console