Reputation: 173
I'm trying to output strings in an array as a sentence and in between the words it outputs the comma that's used to separate the strings and its so annoying.
let words = document.getElementById("Words");
let wordAr = ["This" , "is" , "a" , "test"];
let textIn = document.getElementById("Input");
let timer = 0;
let WPM = 0;
let text = document.getElementById("text");
words.innerHTML = wordAr.slice(0,4);
window.addEventListener("keydown", function(key){
if(key.keyCode == 32){
for (let i=0; i < wordAr.length; i++){
WPM++;
};
console.log("test");
};
});
Upvotes: 1
Views: 51
Reputation: 5472
You can join()
using spaces.
let wordAr = ["This" , "is" , "a" , "test"];
console.log(wordAr.join(' '))
Upvotes: 2