Clarification on code segments for lists in the CT

For the “List” segments of PPR, I’ve noticed some of my students attaching a segment of code where they are creating a list that does not contain data at first which they then add data to later through their procedure(s).

Does a code segment that creates the list but doesn’t fill it count for the first requirement? (The first program code segment must show how data have been stored in the list.)
For example:
var scores = ;

If not, does the procedure that adds items to the list based on the parameters of the function work as both how data is being stored AND how the data is being used since both tend to happen subsequently?

Thanks in advance,
James Hock
Denver Colorado

For the first requirement, students must show how data is being stored in a list, not the creation of the list, so I would not give that line credit. Instead, they would need to include a list initialized with data, or something where we’re pushing data in to the list. For example:

var scores = [];
function addScore(newScore) {
  scores.push(newScore); // <-- This line shows how data is stored
}
addScore(95);
addScore(87);

(It does not need to happen in a fuction, this is just an example!)

1 Like