1 2 3 4 5 6 7 8 9 10 11 12 13
function f(){ var tarr = []; var elemArray = [ {name: "C0", checked: true}, {name: "C1", checked: false}, ]; for (var i = 0; i < elemArray.length; i++) { var element = elemArray[i]; tarr[i] = (element.checked == true) ? 1 : 2; } assertEq(tarr.join(""), "12"); } f();