ryk072018 / front-end-interview

前端面试题总结
0 stars 0 forks source link

[JS] 第 1 题:写一个方法去掉字符串中的空格 #1

Open ryk072018 opened 3 years ago

ryk072018 commented 3 years ago

const str = 'sky so beautiful '

const newStr = str.split(' ').join('')

console.log(newStr)

ryk072018 commented 3 years ago

考点:split() 和 join() 方法 https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/String/split https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/join

ryk072018 commented 3 years ago

问题来源: https://github.com/haizlin/fe-interview/issues/6

https://github.com/haizlin/fe-interview/blob/master/category/js.md