javascript - 如何在 Node Js 环境中反语句
问题描述
I'm doing a practice coding problem and my code doesn't work in this particular environment, how do I get my code work and print multiple lines of sentences backwards. My code starts at "Line 15"
解决方案
您正在使用\b
which 会将“w'w”拆分为w
'
w
.
更好的方法是使用space
.
function reverse(input){
return input.split(' ').reverse().join(' ');
}
console.log(reverse('Hello world'));
console.log(reverse('Hello world 123'));
推荐阅读
- flutter - Flutter中Listview项目的自定义形状
- google-cloud-platform - GCP 无法禁用计算引擎
- python - 为什么 pd.Series(np.zeros(len(data))) 返回 NaN?
- html - 如何使输入文本显示格式为十进制格式 0.00
- java - 如何在JAVA中找到一个数字序列并将这些数字序列与数字2相乘?
- javascript - TypeError:无法读取未定义的属性“案例”
- c# - 您是否必须在启动中为连接字符串的所有 DI 添加服务?
- scala - 在 Spark 中将 DataFrame 保存到 TFRecords 时出错
- node.js - 登录系统nodejs在heroku中不起作用
- php - 我想在每个月开始时将一些数据从表传递到另一个表