我想使用普通javascript在每個單詞的末尾添加一個字母(任意字母,讓說p),但我不知道如何做到這一點。 我已經有這個不完整的代碼。在字符串中的空格之前添加字母
var y = prompt("type a sentence here!"); //person types in sentence that will get changed//
function funkyfunction() {
for(var i=0;i<x.length;i++){
if(x.charAt(i)==" "){
}
}
};
funkyfunction(); //would call the function and print the result
你的意思是'var x = prompt(..)'? –
而你錯過了一個'''' – epascarello
你能否準確解釋你的問題是什麼?確定字符串中的單詞有問題嗎?將字符插入到字符串中?打印字符串?請特別注意** –