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
};
Ответить
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
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