How to add spaces between array values taken from user input when displaying them? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How to add spaces between array values taken from user input when displaying them?

var courses = [ ]; courses[0] = prompt("First course"); courses[1] = prompt("Second course"); courses[2] = prompt("Third course"); document.write(courses); Output=>input1,input2,input3 How can I add spaces between the three inputs when displaying them ?

11th Jan 2021, 6:08 AM
★_★_★
★_★_★ - avatar
3 Answers
+ 9
console.log(courses.join(" "))
11th Jan 2021, 6:17 AM
TOLUENE
TOLUENE - avatar
+ 5
Join the array's elements by ", " console.log( courses.join( ", " ) );
11th Jan 2021, 6:18 AM
Ipang
+ 2
SAYED and Ipang Thank you guys 👍👍👍
11th Jan 2021, 6:21 AM
★_★_★
★_★_★ - avatar