Build a Proofreading Tool - Build a Proofreading Tool

Tell us what’s happening:

My code passes all the tests except for number 16. I’ve checked everything, but it still doesn’t pass.

Your code so far

const isPalindrome = (word) => {
  const wordReverse = word.toLowerCase().split('').reverse().join('')
  return (word.toLowerCase() === wordReverse) ? true : false
}

const findPalindromeBreaks = (words) => {
  const result = []

  for (let i = 0; i < words.length; i++) {
    (!isPalindrome(words[i]))
      ? result.push(i)
      : result;
  }

  return result
}

const findRepeatedPhrases = (words, phraseLength) => {
  const result = [];
  const phrasesToSearch = words.slice(0, phraseLength)

  if (phraseLength < words.length) {
    for (let i = 0; i < words.length; i++) {
      const phrase = words.slice(i, phraseLength++)
      if (phrase.join('') === phrasesToSearch.join('')) {
        result.push(i)
      }
    }
  }
  if (result.length > 1) {
    return result
  }

  return []
}

const analyzeTexts = (texts, phraseLength) => {
  const results = []

  if (texts.length > 0) {
    for (let i = 0; i < texts.length; i++) {
      results.push({ repeatedPhrases: findRepeatedPhrases(texts[i], phraseLength), palindromeBreaks: findPalindromeBreaks(texts[i].join(' ').split(' ')) })
    }
  }

  return results
}

console.log(analyzeTexts([["racecar", "hello", "level", "hello"]], 2))

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36

Challenge Information:

Build a Proofreading Tool - Build a Proofreading Tool

GitHub Link: freeCodeCamp/curriculum/challenges/english/blocks/lab-proofreading-tool/69dd63d1dcdeccb7b39ba4c3.md at main · freeCodeCamp/freeCodeCamp · GitHub

Welcome to the forum @peterson-perez

In the function call you supplied, the text hello is repeated at positions 1, and 3.

EDIT:

When the second argument is 1, the repeatedPhrases key should contain a value of [1, 3].

Happy coding