Got string, need to delete same words from there.
Here is my code. I tried to split string into array and then sort but it didn't work. It didn't even go through my if
. I would like to hear your advice and maybe working code :)
var str = "I wont go anywhere as soon as I wont go there";
var array = str.split(" ");
document.getElementsByTagName('p')[0].innerHTML = str;
document.getElementsByTagName('p')[1].innerHTML = array;
document.getElementsByTagName('button')[0].onclick = function () {
for (var i = 0; i < array.length; i++) {
if (array[i] == array[i + 1]) {
array.splice(i, 1);
}
}
document.getElementsByTagName('p')[2].innerHTML = array;
}