Hello everyone for the following lesson
for the Active learning: Filling in a guest list
why the replacing miss behave here
for(i=0;i<people.length;i++){
if(people[i]===‘Phil’ || people[i]===‘Lola’){
refused.textContent += people[i] + ', ’ ;
}else{
admitted.textContent += people[i] + ', ';
}
}
console.log(refused.textContent.length);
// removing the extra space
refused.textContent = refused.textContent.trimEnd();
console.log(refused.textContent.length);
//replacing the comma with .
refused.textContent = refused.textContent.replace(refused.textContent[refused.textContent.length-1],‘.’);
console.log(refused.textContent);
console.log(admitted.textContent.length);
admitted.textContent = admitted.textContent.trimEnd();
console.log(admitted.textContent.length);
admitted.textContent = admitted.textContent.replace(admitted.textContent[admitted.textContent.length-1],‘.’);
console.log(admitted.textContent);
it replace the comma after the first name not the last one
can anyone let me know what i am missing here
i know there a solution to it but i want to discover what i a missing
thanks and have a nice day