Wanted to challenge your coding skills with this one! Can you identify the issue in the code below?
function run(){
for(var i=0;i<arguments.length;i++){
var type=arguments[i].split(" ")[0];
if(type=="(write)"){
var arr=arguments[i].split(" ");
var str=[];
for(var i=1;i<arr.length;i++){
str.push(arr[i]);
}
var fin="\n"+str.join(" ");
document.getElementById("console").textContent+=fin;
}
}
}
run(
"(write) I wonder if this works.",
"(write) I think it DOES!"
);
Currently, only "I wonder if this works." is being displayed in the div and not "I think it DOES!". What's causing this issue? Could you provide the corrected version of the script?