javascript - 如果我复制并粘贴它,为什么它没有 console.log() 任何东西?
问题描述
我在Glitch上运行此代码以在对话前添加 \n,如果我在 toFormat 中的单词所在的空间中输入一些内容,它可以正常工作,但如果我将某些内容复制并粘贴到其中,它不会 console.log 任何内容
/* !!! */
let toformat = `
“Excuse me,” he said. The young woman didn’t respond. “What are you doing?” “Hey, I’m talking to you” Rudy said.
`
/* !!! */
let truef = false
/* !!! */
let run = true
/* !!! */
if(run){
let res = []
let dialogue = []
let other = []
let split = toformat.split('"').join('|"').split('|').slice(1)
split.forEach((x, i) => {
if(i % 2 == 1){
other.push(x)
} else {
dialogue.push(x)
}
})
for(let i = 0; i < dialogue.length; i++){
res.push('\n' + dialogue[i] + '"')
res.push(other[i].slice(1))
}
console.log(res.join(''))
console.log(Math.random())
}
解决方案
推荐阅读
- cql - ScyllaDB:物化视图未更新
- java - 使用在其外部线程中更新的 arrayList 值
- c# - 保持 Web API Player 登录并在 Unity 中更改场景。(ASP.NET Web API - Unity)
- javascript - 如何在 React Native 中从 google 获取 Lat 和 Long
- postgresql - Postgresql 12 二进制无效,密码不正确(Windows 7)
- python - 在 Python 中自动进行 Winmerge 比较
- r - SAS Proc PSMATCH 与 R Matchit 倾向得分匹配样本
- c# - 无法在 .net mvc Web 应用程序中正确序列化列表
- python - 设置自定义刻度标签
- html - 内部树视图元素在 chrome 中不可见,在 IE11 中可见