Build a Calculator - Step 15

Tell us what’s happening:

Hi fellow FCC students!

I’m trying to solve this step but can’t figure out the solution. Can someone please help.

Your code so far

function calculateSum(num1, num2) {
  return num1 + num2;
}

console.log(calculateSum(2, 5));
console.log(calculateSum(10, 10));
console.log(calculateSum(5, 5));

function calculateDifference(num1, num2) {
  return num1 - num2;
}

console.log(calculateDifference(22, 5));
console.log(calculateDifference(12, 1));
console.log(calculateDifference(17, 9));

function calculateProduct(num1, num2) {
  return num1 * num2;
}

console.log(calculateProduct(13, 5));


// User Editable Region

function calculatQuotient(num1,num2) {
  return num1 / num2;
}
console.log(calculateQuotient(3,0))

// User Editable Region


console.log(calculateQuotient(7, 11));
console.log(calculateQuotient(3, 0));

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36

Challenge Information:

Build a Calculator - Step 15

You need to add a conditional statement before the return statement, to check if the divisor (i.e. num2) is 0. If it is, you need to return the specified error message, instead of the quotient.

Do you understand how to do this?

1 Like