Why i get NaN in my code result

function payment(num1, num2) {

return num1 + num2;

}

function newPayment(num1, num2){

return payment * 60;

}

const total = newPayment(3,8)

console.log(total)
hi could someone tell me why i get NaN in my code result

payment is undefined.

undefined * 60  =>  NaN
1 Like

function payment(num1, num2) {

return num1 + num2;

}

function newPayment(num1, num2){

return payment * 60;

}

const total = newPayment(3,8)

console.log(total)
hi how i define payment as im carrying the value over to the new function as a helper function

Have you learned how to use helper functions yet?
You can call a function in a function:

function square(num) {
  return num * num;
}

function cube(num) {
  return square(num) * num;
}

console.log(cube(3));

function payment(num1, num2) {

return num1 + num2;

}

function newPayment(num1, num2){

return payment * 60;

}

const total = newPayment(3,8)

console.log(total)
hi could someone tell me why i get NaN in my code result

we can log the values we used for the multiplication:

function newPayment(num1, num2){
   console.log(payment, 60);
   return payment * 60;

}

to see which value might not be a number.

as we can see, you multiple 60 times the function itself. Not the result of calling the function.

thanks… i understand this now