I have a couple of projects where students aren’t getting the results they want.
in this one, it appears the index numbers for the list items are showing up instead of the actual contents of the list.
in this one the students get an undefined return in the two areas where they want list items showing up.
Any and all help with these would be appreciated - I have others with similar problems, so hoping any help I receive here would help with those other projects too.
Thanks, in advance!
the first one you aren’t selecting an index from an array
I.E.
console.log(rollercoasterList[index])
for the second one i commented everything out that was not useful
var stateNames = getColumn("US States", "State Name");
var stateNicknameList = getColumn("US States", "Nickname");
// var filterNickname = [];
// var filterStateName = [];
//filter();
onEvent("randomButton", "click", function () {
showstates();
//filter();
});
// function filter() {
// filterNickname = [];
// filterStateName = [];
// for (var i = 0; i < stateNames.length; i++) {
// if (stateNames[i] == stateChoice) {
// appendItem(filterNickname, stateNicknameList[i]);
// appendItem(filterStateName, stateNames[i]);
// }
// }
// }
function showstates() {
var stateChoice = randomNumber(0, stateNames.length - 1);
var randomStateName = stateNames[stateChoice];
var randomStateNickname = stateNicknameList[stateChoice];
setText("fakeName1", "Aligator state");
setText("fakeName", "Everglade state");
setText("realName", randomStateName + "");
setText("State_Area", randomStateNickname + "");
}