プログラムはあなたがボックスに入力した単語を文字列に分割し、それらをシャッフルすることになっています。その後、最初の文字を大文字にし、残りを小文字にして、同じボックスに出力します。ランダムな文字に単語をスクランブルする
ランダムな文字に単語をスクランブルしようとしていますが、このエラーを回避できません。
私は予期せぬ識別子があり、mozillaにはnewWord = shuffle(newWord)の括弧がないと言っていました。 *固定
編集:現在、私はcapitalizeが関数ではないというエラーがあります。
<html>
<head>
<title>Final</title>
</head>
<body>
<h1>Final</h1> Random Word scrambler
<br>
<input type="text" id="word">
<input type="button" id="submit" value="Randomize" onclick="Random()">
<script language="javascript">
word = document.getElementById("word").value
var n = word.length;
function Random() {
for (var start = 0; start < n; start++) {
var newWord = word.charAT(start)
newWord = shuffle(newWord);
function shuffle(array) {
var currentIndex = array.length,
temporaryValue, randomIndex;
while (0 !== currentIndex) {
randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex -= 1;
temporaryValue = array[currentIndex];
array[currentIndex] = array[randomIndex];
array[randomIndex] = temporaryValue;
}
return array;
}
function capitalize(str) {
return str.replace(/\w\S*/g, function(txt) {
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
});
Array.join(newWord);
}
}
if (newWord == newWord){
document.getElementById("word").value = (capitalize(newWord));
}
}
</script>
</body>
</html>
あなたはB/Cこの行のエラーを取得しています 'VAR newWord =(word.charAT(スタート)'、あなたは、 ' – hackerrdave
('最初と 'charAT'がなければならないことを削除する必要があります'charAt'。 –