Question user-bcc4abdfa1b3ae5c in lesson «The iterative process and how to not be lazy», course «Programming fundamentals»
Does anyone know why I'm getting an error with this function? It seems to work fine if I run it in the Chrome JS console.
const smallestDivisor = (num) => {
// BEGIN (write your solution here)
function iter(val, acc) { // console.log(val, acc) if (val % acc === 0) { return acc; } return iter(val, acc + 1); } return iter(num, 2);
// END
};
1
0
user-bcc4abdfa1b3ae5c, hello! Tests check the operation of a function with different argument options. A function may work correctly with some data and not work with others. Check how the function behaves if you pass 1 to it.
0
Use Hexlet to the fullest extent!
- Ask questions about the lesson
- Test your knowledge in quizzes
- Practice in your browser
- Track your progress
Sign up or sign in
Suggested learning programs
From a novice to a developer. Get a job or your money back!

Profession
beginner
Development of front-end components for web applications
start anytime
10 months

Profession
New
Under development
beginner
Layout with the latest CSS standards
start anytime
5 months