You should use a spread operator if you want to pass an array into math.min and max, they will not work with arrays out of the box. Before a spread operator was around it required some voodoo magic with apply to get it to work
Omitting the let/const just made ‘min’ declared with var behind the scenes. Still a function scope, not using let/const when declaring variables is a terrible practice, but it was not the reason why his code didn’t work and certainly not the reason why min/max were undefined.
p.s. Nvm, scratch that, sorry, didn’t see that the test function is declared outside the main function. The point about min/max being undefined inside smallestCommons() because of the wrong usage of math functions still stands though.
Your problem is your algorithm.Think of ways you can find the smallest common multiple of a few numbers. Write the numbers out on a piece of paper, try to solve it yourself. Think about patterns. If you spend a good 30 minutes focusing on a problem and you are still stuck - take a break. Try again later, let your brain work on this problem in the background while you are doing something else.
If you are still stuck after a few pokes at this you can always look at hints - they do a good job of revealing to you pieces of the puzzle one by one. Don’t despair. You can do this!
First off, I just noticed when you call testCount() you didn’t pass in a value. You should fix that really quick.
As for min not being defined:
You have 2 functions defined in your code: smallestCommons(arr) and testCount(value).
min and max are defined in the first function, but not in the second. I believe the easiest ways to fix that would be
A.) get rid of the testCount function and just put that code in the if statement
B.) pass min and max to the testCount function a la testCount(value, min, max).
Then you should be able to use the variables min and max.