Problem with JavaScript answer

I’ve had an issue where this is getting the error “the sum of both functions should be equal to eight.” What’s the problem with my code?

My code:

// Setup
let sum = 0;

function addThree() {
  sum = sum + 3;

// Only change code below this line
function addFive(){
  sum = sum + 5;
var result = addFive(); // This is undefined
// Only change code above this line


Browser Info:
Browser: Microsoft Edge Version 101.0.1210.47 (Official build) (64-bit)
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.64 Safari/537.36 Edg/101.0.1210.47

Challenge: Understanding Undefined Value returned from a Function

Link to the challenge:

This line is causing a problem. You add 5, add 5 again, and then add 3, so your total is not correct.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.