> let fullInteger = '';
const sentenceText = 'junayed';
for (let i = 0; i < sentenceText.length; i++) {
if (sentenceText[i] == 'n' & sentenceText[i + 1] == 'a') {
let newChar = sentenceText[i]
newChar = 'a';
fullInteger = fullInteger + newChar;
}
else if (sentenceText[i] == 'a' & sentenceText[i - 1] == 'n') {
let newChar = sentenceText[i]
newChar = 'n';
fullInteger = fullInteger + newChar;
}
else{
fullInteger = fullInteger + sentenceText[i];
}
}
console.log(fullInteger);
It will take a string and change it if it finds "na" to "an". Does any of you know how can I shorten it, or any alternative idea?