-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathit_starts_here.js
65 lines (55 loc) · 1.67 KB
/
it_starts_here.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import { println } from "./utils.js";
// //nested if practice
// var lat=37.5;
// var lng=-131.2;
// var direction;
// if (lat > 38 && lng < -134) {
// direction = "NW";
// } else {
// if (lat > 38 && lng > -134) {
// direction = "NE";
// } else {
// if (lat < 38 && lng < -134) {
// direction = "SW";
// } else {
// if (lat < 38 && lng > -134) {
// direction = "SE";
// }
// }
// }
// }
// console.log(direction);
//==================================================================================
// nested loop pracrice
// The program below plants a 5 x 5 field of snowmen.
// Change it to 5 rows of 10 snowmen,
// then 10 rows of 5 snowmen.
var rows = 5;
var snowmenCount = 10; //snowmen per row or columns
for (var i = 0; i < rows; i++) {
var snowmen = "";
for (var j = 0; j < snowmenCount; j++) {
snowmen += " ☃ ";
}
println(snowmen);
}
// A visual artist is programming a 7x7 LED display:
// 7x7 grid of squares.
// This is their program so far:
// rowNum ← 1
// numPixels ← 1
// REPEAT 3 TIMES
// {
// colNum ← 5 - rowNum
// REPEAT (numPixels) TIMES
// {
// fillPixel(rowNum, colNum, "green")
// colNum ← colNum + 1
// }
// numPixels ← numPixels + 2
// rowNum ← rowNum + 1
// }
// The code relies on this procedure:
// fillPixel(row, column, color) : Lights up the pixel at the given row and column with the given color (specified as a string). The top row is row 1 and the left-most column is column 1.
// What will the output of their program look like?
// 750, 77, 737, 714, 672, 668, 655, 634, 629, 618, 615, 610