Question user-bcc4abdfa1b3ae5c in lesson «The iterative process and how to not be 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

};

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
profession
Development of front-end components for web applications
10 months
from scratch
Start at any time
profession
Layout with the latest CSS standards
5 months
from scratch
under development
Start at any time
profession
new
Developing web applications with Django
10 months
from scratch
under development
Start at any time