[問題] javascript for迴圈

看板Web_Design作者 (james)時間17年前 (2008/12/17 09:42), 編輯推噓3(302)
留言5則, 4人參與, 最新討論串1/1
points.push(point1); points.push(point2); points.push(point3); points.push(point4); points.push(point5); points.push(point6); points.push(point7); 以上這段程式碼 在javascript環境下 我用FOR迴圈寫 for(var a=1;a<8;a++){ points.push(point+a);} 請問這樣子有什麼錯嗎? 一直跑不出來 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.128.20.177

12/17 10:41, , 1F
points.push( eval( "point" + a ) )
12/17 10:41, 1F

12/17 10:42, , 2F
請重新研讀Javascript變數章節..
12/17 10:42, 2F

12/17 10:48, , 3F
為什麼不用陣列? 編這麼多獨立變數幹麻?
12/17 10:48, 3F

12/17 11:27, , 4F
請問 用陣列是要如何寫呢? 小弟我不才 程式底子不好
12/17 11:27, 4F

12/17 13:58, , 5F
建議您可以找相關書籍....
12/17 13:58, 5F
文章代碼(AID): #19I5ZwGr (Web_Design)
文章代碼(AID): #19I5ZwGr (Web_Design)