いくつかの配列と単純なコンストラクターがありますが、どういうわけかうまくいきません。
var suit = ["ruutu", "risti", "\u00E4rtu", "poti"],
type = ["2", "3", "4", "5", "6", "7", "8", "9", "10", "soldat", "emand", "kuningas", "\u00E4ss"],
pnt = [2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 11],
card = {}, // 3 properties: suit, type, pnt)
Cards = [];
Cards = makeDeck(card, suit, type, pnt, Cards);
card = new NewCard(Cards);
function makeDeck(card, suit, type, pnt, Cards) {
"use strict";
var i,
j;
for (i = 0; i < 4; i = i + 1) {
for (j = 0; j < 13; j = j + 1) {
card = {
suit : suit[i],
type : type[j],
pnt : pnt[j]
};
Cards.push(card);
}
}
return Cards;
}
function NewCard(Cards) {
"use strict";
var i = Math.floor(Math.random() * 52);
this.suit = Cards[i].suit;
this.type = Cards[i].type;
this.pnt = Cards[i].pnt;
}
Firebug を見ると、this.suit と this.type が値を取得している間、this.pnt は未定義のままです。なんで?データ型 (数値と文字列) と関係がありますか?
前もって感謝します!