Question user-bcc4abdfa1b3ae5c in lesson «Iterative process and not being lazy», course «Programming fundamentals»

user-bcc4abdfa1b3ae5c

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.

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

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

Suggested learning programs

From zero to a developer. Refunds in case you won't get a job

Frontend Developer icon
Profession
New
Development of front-end components for web applications
start anytime 10 months