编程练习
来源:2-11 编程练习
卷毛奋斗中
2022-07-16 11:36:48
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
let str = "study hard and make and progress every day study"
//先将字符串转换成数组
let arr = str.split(' ');
//将数组作为参数传入到Set中
let s = new Set(arr);
//使用扩展运算符在数组中展开set,将set转换成数组
let newArr = [[...s].join(' ')];
document.write(newArr);
</script>
</body>
</html>1回答
好帮手慕星星
2022-07-16
同学你好,最后直接输出字符串即可,不需要再放到数组中。如下:

祝学习愉快!
相似问题