My analyzeText method is not working not only because I am confused on how to interpret the request but because of my findRepeatedPhrases not exactly working well with analyzeText. Although my findRepeatedPhrases, passes all check within its own checkbox criteria, it is likely causing issues with the analyzeTexts.
Your code so far
function isPalindrome(word)
{
let count = 0
for(let i = 1; i <= word.length; i++){
if(word[i-1].toLowerCase() === word[word.length-i].toLowerCase())
{
count++
console.log(count)
if(count == word.length){return true}
}
else return false
}
}
function findPalindromeBreaks(words)
{
let countMissingPals = []
if(words == "")
{
return []
}
for(let i = 0; i < words.length; i++)
{
if(!isPalindrome(words[i]))
{
countMissingPals.push(i)
}
}
return countMissingPals
}
function findRepeatedPhrases(words, phraseLength)
{
let moreThanOnce = []
let result = []
if(phraseLength >= words.length){return []}
for(let i = 0; i < words.length; i++)
{
if(moreThanOnce.includes(words[i]))
{
console.log(i + " index of word appearing more than once")
console.log(moreThanOnce.indexOf(words[i]) + " earlier appearance")
if(result.length == 0)
{
result.push(moreThanOnce.indexOf(words[i]))
//console.log(moreThanOnce[])
//console.log(result)
}
if(result.length > 0 && words[i] == moreThanOnce[0])
{
result.push(i)
//console.log(result)
}
console.log(words[i] + " is repeatedWord")
}
moreThanOnce.push(words[i])
//for(let j = 0; j < moreThanOnce)
}
return result
console.log(moreThanOnce + " array")
}
function analyzeTexts(texts, phraseLength)
{
if(texts.length == 0)
{
return []
}
const obj = {
repeatedPhrases: findRepeatedPhrases(words, phraseLength),
palindromeBreaks: findPalindromeBreaks(words)
};
}
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:150.0) Gecko/20100101 Firefox/150.0
Challenge Information:
Build a Proofreading Tool - Build a Proofreading Tool
analyze text needs to return an array of objects with the two properties repeatedPhrases and palindromeBreaks as mentioned. However mine are all empty arrays. It looks like I am missing something to better understand what it is that I am missing. Here is my updated function:
Please post all of your code so it can be tested, and format it as follows:
There are two ways you can format your code to make it easier to read and test:
After you copy/paste your code into the editor, select it by dragging your cursor 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.)
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.
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: