# minNum undefined why?

``````
function smallestCommons(arr) {
var min =Math.min(...arr), max = Math.max(...arr);
var multiples = 1;
var range = getRange(minNum, maxNum);
while(multiples < 1000){

var higherCommons = min * multiples* max;

multiples+=1
}
return arr;
}

function getRange(minN, maxN){
var limitedRange = [];
for(var i = minN; i <= maxN; i++){
limitedRange.push(i)
}
return limitedRange;
}

smallestCommons([1,5]);

``````

Please I need somebody to tell me why pieces of code consolelog"minNum is not defined"?

User Agent is: `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.122 Safari/537.36`.

Challenge: Smallest Common Multiple

It says that the variable `minNum` (and `maxNum`) are not defined because they are not. In `smallestCommons` you define `min` and `max` but never `minNum` and `maxNum`.

Thanks .But in someway I’m confused for I reasoned that minNum have been defined through the argument in the getRannge function. And I was only using the variable range to store the callback if I may be correct. Or what do you think pls? Do we need to define an argment? I really need help ! Pls never mind me bothering you!

There is a difference between the variables used when a function is defined and when it is called.

Consider this example

``````function mySum(num1, num2) {
return num1 + num2;
}

let var1 = 2;
let var2 = 5;

// This works
console.log(mySum(var1, var2));

// This fails
console.log(mySum(num1, num2));
``````

The arguments you use when you call the function need to be defined.

But I think the arguments for getRange (minN, maxN) are already provided in the call back function of smallestCommons([1,5]) since getRange is called within the smallestCommons function ie getRange(minNum, maxNum). I may be very wrong but that is how i understand it now. But i certainly need some clarifications pls.

Did you try the code I provided? Please run this code in repl.it to see what I am talking about. You could also try http://pythontutor.com/visualize.html.

``````// Function definition
function mySum(num1, num2) {
return num1 + num2;
}

let var1 = 2;
let var2 = 5;

// Function calls
// -- This works and logs 7
console.log(mySum(var1, var2));

// -- This fails with an error message
console.log(mySum(num1, num2));
``````

The variable names in function definition and the function call do not need to match. The variable names in the function call must be defined.

Good that worked fine! Thanks.Trying to reconcile this with my own pieces of code, is it logical then to say that the only arguments provided in the callback function of smallestCommons([1,5]) rigthly defined the arguments of the function getRange(minN,maxN) since it is finally calledback within the function smallestCommons(arr) itself as getRange(minNum, maxNum) and stored in the variable range? pls Otherwise how do i go about defining my minNum and maxNum considering the entire code? pls never mind my newbie-minded questions? I just want to get out of this for once!