Counting Sheep Recursivly Test Error


I'd like to mention the Counting Sheep Recursivel allows for the user to pass the exercise by calling the countSheepWithLoop() .

Below is a reference to what I am talking about:

 // Here is the function using a for loop
function countSheepWithLoop(number) {    
  for (i = 1; i <= number; i++) {
    if (i === number) {
    console.log("Another sheep jumps over the fence.");

// And here is the recursive function
function countSheep(number) {
  if (number === 0) {
    return console.log("Zzzzzz");     
    } else {
	console.log("Another sheep jumps over the fence.");
	// Define the variable newNumber as 
	// 1 less than the input variable number
	newNumber = number - 1; 
	// Recursively call the function
	// with newNumber as the parameter
countSheepWithLoop(12);  // This passes

I also could not find a confirmed category but I attempted to find the most appropriate spot for it.

Here the problem link:


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.