Build a Calculator - Step 15

Tell us what’s happening:

The assignment wants me to check if num2 is equal to zero. My if/else is returning an error.

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 calculateQuotient(num2 === "0") 
  return "Error: Division by zero";
  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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36 Edg/142.0.0.0

Challenge Information:

Build a Calculator - Step 15

[Spoilers]
Here your logic is not correct you want to check if want num2 equal 0 and you give him a function calculateQuotient() that why . For correction just give.

code removed by moderator

Happy Coding :+1::ok_hand:

hi @LaudeDignus

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge. How to Help Someone with Their Code Using the Socratic Method

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.