# Code Efficiency

Tell us what’s happening:
So, my question is that using for loop is efficient compared to built in functions like map(), reduce()?

``````
function findLongestWordLength(str) {

let maxCount = 0;
let counter = 0;

for(let i = 0; i < str.length; i++) {
if(str[i] != ' ' && str[i] != '
'){
console.log(counter);
counter++;
}
else {
counter = 0;
}
if(maxCount < counter){
maxCount = counter;
}
}
let call = findLongestWordLength("What if we try a super-long word such as otorhinolaryngology");
console.log(call);
``````

User Agent is: `Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.5 Safari/605.1.15`.
methods like `map` and `reduce` are doing loops under the covers.
You might want to look into time complexity and Big O notation. Like @ArielLeslie said, `map` and `reduce` are doing loops without you seeing them.
A basic `for` loop as a time complexity of O(n) because you need to touch every element at least once. So it’s linear time.
Since the `map` is like a for loop, the time complexity is O(n) as well. They’re both equivalent at the base.