Build a Calculator - Step 15

Tell us what’s happening:

hey this wont pass, it says "your calculateQuotient function should return the string “Error: Division by zero” if num2 is zero. "
“your calculateQuotient function should return the result of dividing num1 and num2 if num2 is not zero.”

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 calculateQuotient(num1, num2) {
  if (num2==0)
    return "Error: Division by zero"
  else 
    return num1/num2;



// User Editable Region


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

Your browser information:

User Agent is: Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36

Challenge Information:

Build a Calculator - Step 15
https://www.freecodecamp.org/learn/full-stack-developer/workshop-calculator/step-15

are there any errors in the Console area?
(i see a missing brace in your code so I’m wondering about that)

yes i was missing a bracket at the bottom of the code. The one in the console is there on the project, idk why it didnt transfer here. But i was missing the bottom bracket of the section i was editing. thank you

1 Like