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

Ivan Gagarinov

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.


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

By sending this form, you agree to our Personal Policy and Service Conditions
Suggested learning programs

From a novice to a developer. Get a job or your money back!

Frontend Developer icon
Development of front-end components for web applications
start anytime 10 months
Layout Designer icon
New Under development beginner
Layout with the latest CSS standards
start anytime 5 months