老师这样对吗?
来源:2-11 编程练习
淡淡嚣风
2021-04-23 16:16:00
相关代码:
<!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";
const s = new Set([...str]);
document.write([...s].join(''));
</script>
</body>
</html>
1回答
同学你好,效果不对。同学打印的结果中,多余的空格也被去掉了:
应该保留单词之间的空格。可参考如下实现:
祝学习愉快!