Build a Proofreading Tool - Build a Proofreading Tool

Tell us what’s happening:

I just don’t understand user story 3, am I looking for any phrase of a specific length? any time a phrase of a specific length which appears more than once? Or only if it appears concurrently? (ignore my code tbh, I’m just plain confused)

Your code so far

function isPalindrome(word){
let count = 0;
word= word.toLowerCase()
let wordArray = word.split("")
let j = wordArray.length-1;
for(let i = 0; i< wordArray.length; i++){
if(wordArray[i] === wordArray[j]){
  count++
}
j--
}
console.log(count)
if(count === wordArray.length){
return true
}
else{
  return false
}

}

function findPalindromeBreaks(words){
  let arrayOfIndices = [];
  for (let i = 0; i<words.length; i++){
      if (!isPalindrome(words[i])){
        arrayOfIndices.push(i);
    }
  }
  return(arrayOfIndices)
}

function findRepeatedPhrases(words, phraseLength){
//return all start indices where a sequencce of "phraseLength" consecutive words appears more than once 
let indices=[];
let count = 0;
if(phraseLength => words.length){
  return indices
}
//check if current word appears at any time
  //if it does, then push it 
for (let i =0; i<words.length; i++){
  //check if indice is already in the indices array
  if (!indices.includes(words[i])){
//check if current word repeats at any time 
    count = 0
    for(let j = 0; j<words.length; j++){
      if (words[i] === words[j]){
        indices.push(j)
      }
    }
  }
  }
  return indices
}


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

Hi @n-otoole,

Yes; you are looking for a phrase with a length of the phraseLength parameter that occurs consecutively (one right after the other) in the words array.

Happy coding

Hi,

Thank you for this, I think I’m understanding a bit more now- would you have an example array and phraseLength and what the expectation is for the code to answer? I’m definitely closer than before but think my lack of success is from not really understanding what the expected outcome is

The instructions provide an example:

A phrase is a sequence of consecutive words. For example, in ["the", "cat", "sat", "the", "cat"], the phrase "the cat" (a sequence of 2 words) appears at positions 0 and 3.