# ‘16-‘17 General Discussion for Lesson 5.15

#1

#2

Hi All,

I thought I would share this out for anyone else interested. I did the ColorSleuth project as a class with a lot of back and forth - posing questions to the class about how we should program it, having them talk in teams, and then share ideas, do a bit of code and then repeat. That structure worked really well.

I was interested in doing something else like that with my students and came up with this basic “Simon” game - although instead of colored buttons, there are arrows that flash up. The goal was to 1) get students comfortable with using arrays, 2) gain familiarity with input from a keyboard, 3) give them something they could build on later. It worked out really well. Here is the code that we started with and here is where we ended as a class - students made extensions as a team to the project. wrote a bit more about this experience here too.

I am looking into doing something similar to this again - my current idea is for a memory game but I’m interested in other suggestions for class projects too - games seem to work best, but I’m open to suggestions!

#3

Question on Lesson 5, Stage 15.15. I’m stuck at the moment and I am not sure of how to proceed. Any help would be greatly appreciated. Here’s the code I have so far:

var array1 = [1,3,4,6,7,6];
var array2 = [6,2,7,2,5,6,1,3,7];
var arrayRandom = [];
for (var i = 0; i < 10; i++) {
appendItem(arrayRandom, randomNumber(0,100));
}

findMinVal(array1);
findMinVal(array2);
findMinVal(arrayRandom);

function findMinVal(list){

console.log(“Original:” + list);

//What value should minVal start off as? Set its value before your loop.

var minVal =0;

for (var i = 0; i < list.length; i++) {
if(i<minVal){

appendItem.list.length;

``````//Update your minimum value on each iteration of the loop
``````

}

console.log("The smallest value in the array is: " + minVal);

#4

It’s a few things.

1. Set minVal to a really big number. And update it in the for loop.
2. Your if(i<minVal) doesn’t make sense. You don’t want to compare the index (i) to the minVal. You want to compare the value of the array at index i. In other words list[i]<minVal
3. Inside the if loop you want to update the minVal not add onto the array.

Here is an updated version of the code.

var array1 = [1,3,4,6,7,6];
var array2 = [6,2,7,2,5,6,1,3,7];
var arrayRandom = [];
for (var i = 0; i < 10; i++) {
appendItem(arrayRandom, randomNumber(0,100));
}

findMinVal(array1);
findMinVal(array2);
findMinVal(arrayRandom);

function findMinVal(list){

console.log(“Original:” + list);

//What value should minVal start off as? Set its value before your loop.
var minVal = 101;

for (var i = 0; i < list.length; i++) {

if(list[i]<minVal){

``````minVal = list[i];

//Update your minimum value on each iteration of the loop
}
``````

}

console.log("The smallest value in the array is: " + minVal);
}

#5

Appreciate the help, thanks!