codedamn

Loops - Challenge Solution

Created by Muslim helalee about 5 months ago

0

No description

1 Comment

    0

    There is a small correction in the Long Version of the solution.

    for (let searchItem of SearchHistory) {
      let searchString = searchItem.split(" ") // .split() method returns an array, it doesn't modify the existing string
      for (let entry of searchString) { // use the new created array variable
        if (entry === 'html' || entry === 'css') {
          console.log('....')
        }
      }
    }
    

    Additionally, it's always ideal to use .forEach instead of .map in the short version, as we are not mutating / modifying the current array of strings.

    .map method is ideally meant for creating a new array by modifying the contents of the existing data.

    @pranavtechie

    Pranav Mandava

    @pranavtechie

Your comment