zilongxuan001 / LearnFreecode

0 stars 0 forks source link

Join Strings with join #286

Open zilongxuan001 opened 6 years ago

zilongxuan001 commented 6 years ago

介绍

join方法把数组的元素组成字符串。

方法

and连接数组里的元素。

var veggies = ["Celery", "Radish", "Carrot", "Potato"];
var salad = veggies.join(" and ");
console.log(salad); // "Celery and Radish and Carrot and Potato" 

练习

Use the join method to create a string from joinMe with spaces in between each element and assign it to joinedString.

代码


var joinMe = ["Split","me","into","an","array"];
var joinedString = '';

// Only change code below this line.

joinedString = joinMe.join(' ');

结果显示

image

来源

https://www.freecodecamp.org/challenges/join-strings-with-join