Skip to content
Advertisement

Converting nested loops into forEach();

Im trying to learn forEach() method but i cant find more advanced examples. So i thought about refactoring my Codewars code to learn from it. I dont know know to properly use forEach method in nested loops. Hope You can help me learn from this example 🙂

6 kyu – Replace With Alphabet Position https://www.codewars.com/kata/546f922b54af40e1e90001da/train/javascript

JavaScript

Advertisement

Answer

(Note: @Terry’s solution is still the more efficient solution to your code challenge)

You can replace it in the following way:

JavaScript
Advertisement