I did it, but why it's undefined?



I did this exercise, but it doesn't shows the result, it shows "undefined", why?

var orange = 5;
function orangeCost(){
  var val = orange * 5;  



The function has no return value, so JavaScript reports it as undefined. Your function should take a parameter, not use a global variable.

function orangeCost(price) {
    return ...


Ok, now I understand


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