# Build a Proofreading Tool Test 12

**URL:** <https://forum.freecodecamp.org/t/build-a-proofreading-tool-test-12/789514>\
**Category:** Curriculum Help\
**Tags:** javascript\
**Created:** [May 21, 2026, 4:51pm UTC](https://forum.freecodecamp.org/t/build-a-proofreading-tool-test-12/789514 "2026-05-21T16:51:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![shawdowdancer14](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/shawdowdancer14/32/414740_2.png) [@shawdowdancer14](https://forum.freecodecamp.org/u/shawdowdancer14)\
**Post date:** [May 21, 2026, 4:51pm UTC](https://forum.freecodecamp.org/t/build-a-proofreading-tool-test-12/789514/1 "2026-05-21T16:51:33Z")

</div>

I’ve gotten every test but this one to pass. It worked for a moment when just run through repeatedPhrases, but when going through analyze texts, it says “arr.filter is not function”.

> function isPalindrome (word) {
> 
> word = word.toLowerCase();
> 
> let reverseWord = “”;
> 
> for (let i = 0; i \< word.length; i++) {
> 
> ```
> reverseWord = word.charAt(i) + reverseWord;
> 
> ```
> 
> }
> 
> if (reverseWord == word) {
> 
> ```
> return true;
> 
> ```
> 
> }
> 
> return false;
> 
> }
> 
> function findPalindromeBreaks(wordArr) {
> 
> const notPalindrome = [];
> 
> for (let i = 0; i \< wordArr.length; i++) {
> 
> ```
> const isItPalindrome = isPalindrome(wordArr\[i\]);
> 
> if (!isItPalindrome) {
> 
> notPalindrome.push(i);
> 
> }
> 
> ```
> 
> }
> 
> return notPalindrome;
> 
> }
> 
> function findRepeatedPhrases (words, phraseLength) {
> 
> const repeatedPhrases = [];
> 
> if (phraseLength \>= words.length) {
> 
> ```
> return repeatedPhrases;
> 
> ```
> 
> };
> 
> let findDuplicates = arr =\> arr.filter((item, index) =\> arr.indexOf(item) !== index)
> 
> const duplicateArray = findDuplicates(words);
> 
> const dupeCheck = [];
> 
> for (let i = 0; i \< words.length; i++) {
> 
> ```
> if (duplicateArray.includes(words\[i\])) {
> 
> dupeCheck.push(words\[i\]);
> 
> }
> 
> ```
> 
> }
> 
> if (dupeCheck.length - 1 \>= phraseLength) {
> 
> ```
> for (let i = 0; i < words.length; i++) {
> 
> if (duplicateArray.includes(words\[i\])) {
> 
> repeatedPhrases.push(i);
> 
> }
> 
> }
> 
> ```
> 
> }
> 
> return repeatedPhrases;
> 
> }
> 
> function analyzeTexts (texts, phraseLength) {
> 
> let analyzedTexts = [];
> 
> for (let i = 0; i \< texts.length; i++) {
> 
> ```
> const palindromeCount = findPalindromeBreaks(texts\[i\]);
> 
> const repeatedWords = findRepeatedPhrases(texts\[i\], phraseLength);
> 
> let textObject = {
> 
> palindromeBreaks: palindromeCount,
> 
> repeatedPhrases: repeatedWords
> 
> }
> 
> analyzedTexts.push(textObject);
> 
> ```
> 
> }
> 
> return analyzedTexts;
> 
> }

[Link to Lab](https://www.freecodecamp.org/learn/javascript-v9/lab-proofreading-tool/build-a-proofreading-tool)

---

<div class="post-metadata">

**Author:** ![dhess](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/dhess/32/406235_2.png) [@dhess](https://forum.freecodecamp.org/u/dhess)\
**Post date:** [May 21, 2026, 5:38pm UTC](https://forum.freecodecamp.org/t/build-a-proofreading-tool-test-12/789514/2 "2026-05-21T17:38:34Z")

</div>

Hi @shawdowdancer14,

Please format your code so we can test.

* * *

There are two ways you can format your code to make it easier to read and test:

1. After you copy/paste your code into the editor, select it by dragging your mouse over it then click the (`</>`) button in the toolbar to automatically wrap your code in backticks. (You can click on the animated demo image below to enlarge it.)

 ![](https://global.discourse-cdn.com/freecodecamp/original/3X/1/b/1b18854f1059217f29370444396145cc3a0cd8ae.gif)

1. Manually add three backticks on a new line above your code and on a new line after your code. Note that a backtick is NOT the same as a single quote('). To find the backtick key on your keyboard, see [this post](https://forum.freecodecamp.org/t/forum-code-formatting/25574).

To see changes to your post as you make them, you can click the (`M+`) button on the toolbar to bring up the rich text editor:

 ![image](https://global.discourse-cdn.com/freecodecamp/original/4X/a/a/1/aa16828d97d1fd4a1aa0f864a850415f01dc9d2b.png)

* * *

---

<div class="post-metadata">

**Author:** ![shawdowdancer14](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/shawdowdancer14/32/414740_2.png) [@shawdowdancer14](https://forum.freecodecamp.org/u/shawdowdancer14)\
**Post date:** [May 21, 2026, 7:10pm UTC](https://forum.freecodecamp.org/t/build-a-proofreading-tool-test-12/789514/3 "2026-05-21T19:10:54Z")

</div>

Sorry I was in a rush in I wrote it. Here’s it properly formatted.

```auto
function isPalindrome (word) {
  word = word.toLowerCase();
  let reverseWord = "";
  for (let i = 0; i < word.length; i++) {
    reverseWord = word.charAt(i) + reverseWord;
  }
  if (reverseWord == word) {
    return true;
  }
  return false;
}

function findPalindromeBreaks(wordArr) {
  const notPalindrome = [];
  for (let i = 0; i < wordArr.length; i++) {
    const isItPalindrome = isPalindrome(wordArr[i]);
    if (!isItPalindrome) {
      notPalindrome.push(i);
    }
  }
  return notPalindrome;
}

function findRepeatedPhrases (words, phraseLength) {
  const repeatedPhrases = [];
  

  if (phraseLength >= words.length) {
    return repeatedPhrases;
  };

  let findDuplicates = arr => arr.filter((item, index) => arr.indexOf(item) !== index)
  
  const duplicateArray = findDuplicates(words);
  const dupeCheck = [];

  for (let i = 0; i < words.length; i++) {
    if (duplicateArray.includes(words[i])) {
      dupeCheck.push(words[i]);
    }
  }

  if (dupeCheck.length - 1 >= phraseLength) {
    for (let i = 0; i < words.length; i++) {
      if (duplicateArray.includes(words[i])) {
        repeatedPhrases.push(i);
      }
    }
  } 
  return repeatedPhrases;
}

function analyzeTexts (texts, phraseLength) {
  let analyzedTexts = [];

  for (let i = 0; i < texts.length; i++) {
    const palindromeCount = findPalindromeBreaks(texts[i]);
    const repeatedWords = findRepeatedPhrases(texts[i], phraseLength);

    let textObject = {
      palindromeBreaks: palindromeCount,
      repeatedPhrases: repeatedWords
    }

    analyzedTexts.push(textObject);
  }
  return analyzedTexts;
}

```

---

<div class="post-metadata">

**Author:** ![dhess](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/dhess/32/406235_2.png) [@dhess](https://forum.freecodecamp.org/u/dhess)\
**Post date:** [May 21, 2026, 7:29pm UTC](https://forum.freecodecamp.org/t/build-a-proofreading-tool-test-12/789514/4 "2026-05-21T19:29:12Z")

</div>

Thank you.

It looks like your `findRepeatedPhrases` function is returning the index of both words in a duplicate phrase rather than just the first index where the phrase occurs.

For example, if you test your function like this:

`console.log(findRepeatedPhrases(["the", "cat", "sat", "the", "cat"],2))`

your function returns` [0, 1, 3, 4]`, but `[0, 3]` is expected.

Hope that helps.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/freecodecamp/original/3X/e/1/e1c433102e34b46dfaa3e15d13ab9a514b127078.svg) [@system](https://forum.freecodecamp.org/u/system)\
**Post date:** [June 18, 2026, 7:29pm UTC](https://forum.freecodecamp.org/t/build-a-proofreading-tool-test-12/789514/5 "2026-06-18T19:29:43Z")

</div>

Closed on June 18, 2026, 7:29pm UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
