check every item in loop before returning

Instead of an else statement inside for loop, put that outside of loop if loop does not return.

for (let i = 0; i <= 5; i++) { if (i % 2 === 0) return true; } return false;

Comments

Popular posts from this blog

Code Wars: String incrementer

Code Wars: Find the odd int

Udemy JS Algorithms & Data Structures Masterclass- Section 6 Exercise 8 (1st try)