gpt4 book ai didi

javascript - 错误 : "missing ; before statement"

转载 作者:行者123 更新时间:2023-11-30 17:48:04 25 4
gpt4 key购买 nike

我正在制作一个简单的程序来帮助回答我在历史作业中遇到的某种类型的问题。该代码旨在搜索问题,找到任何 __s,并为每个问题填入您的输入。然而,我在第 5 行收到一个“missing ; before statement”错误。帮忙?

var Que = prompt("Insert your completion question");
var Leng = Que.length;
for (var i = 0; i <= Leng; i+=1){
if (Que.substring(i,i + 4) === "____"){
var newword = prompt Que.substring(0, i + 4);
Que.replace("____", newword);
if (newword.length !== 4){
var i = newword.length - 4 + i;
}
}
}
console.log(Que);

最佳答案

在第 5 行用方括号括起对“提示”函数的调用:

var Que = prompt("Insert your completion question");
var Leng = Que.length;
for (var i = 0; i <= Leng; i+=1){
if (Que.substring(i,i + 4) === "____"){
var newword = prompt(Que.substring(0, i + 4));
Que.replace("____", newword);
if (newword.length !== 4){
var i = newword.length - 4 + i;
}
}
}
console.log(Que);

关于javascript - 错误 : "missing ; before statement",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19698607/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com