Lesson 9 Challenge 1

by nathanesa

JavaScript

var lunches = [17, 10, 14, 15, 12, 12, 14, 9, 12, 23, 6, 12, 24, 10, 4, 16, 17, 10, 21, 23, 3, 20, 8, 7];
var noOfLunches = 24;

for (i = 0; i < noOfLunches; i++) {
	if (lunches[i] < 6) {
		starRating = 5;
	} else if (lunches[i] < 10) {
		starRating = 4;
	} else if (lunches[i] < 15) {
		starRating = 3;
	} else if (lunches[i] < 20) {
		starRating = 2;
	} else {
		starRating = 1;
  }
	
	document.write('Lunch no. ' + i + ' gets ' + starRating + ' stars.<br>');
}