I am learning/refreshing/playing with data. In this example, I am looking for even and odd length string in sentence. But character for new line is not working. Can you show me what am I doing wrong? THANK YOU.
const evenOddLength = (t: string) => {
let text = strings.split(' ')
const even: string [] = []
const odd: string [] = []
for(let i = 0; i < text.length; i++) {
if(text[i].length % 2 === 0) {
even.push(text[i])
} else {
odd.push(text[i])
}
}
setOutput(`Even string: [ ${even} ],` + "\n" + ` Odd string: [ ${odd} ]`)
}
Expected output should be:
Even string: [ String,be,iterated,loop ],
Odd string: [ The,Array,can,using,the,for ]
but I am getting :
Even string: [ String,be,iterated,loop ], Odd string: [ The,Array,can,using,the,for ]
{output}
– erza May 01 '23 at 03:56