본문 바로가기

html | javascript

html javascript - array join

const arr = [1,2,3,4,5,6,7,8,9]
const arrJoin0 = arr.join(',')
const arrJoin1 = arr.join('/')
let arrJoin2 = arr.join('won ') // 1won 2won 3won 4won 5won 6won 7won 8won 9
arrJoin2 += 'won'
const arrJoin3 = arr.join('')
console.log(arrJoin0) // 1,2,3,4,5,6,7,8,9
console.log(arrJoin1) // 1/2/3/4/5/6/7/8/9
console.log(arrJoin2) // 1won 2won 3won 4won 5won 6won 7won 8won 9won
console.log(arrJoin3) // 123456789