Skip to content

Commit 80bd3a1

Browse files
authored
Update build-a-k-nearest-neighbor-model-with-p5js.mdx
1 parent cf055ee commit 80bd3a1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

projects/build-a-k-nearest-neighbor-model-with-p5js/build-a-k-nearest-neighbor-model-with-p5js.mdx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ class Point {
101101
}
102102

103103
display() {
104-
105104
stroke(0);
106105
strokeWeight(2);
107106

@@ -151,6 +150,7 @@ Finally, in the `draw()` function, loop through your list and call `.display()`
151150
```javascript
152151
function draw() {
153152
background(255);
153+
154154
for (var i = 0; i < points.length; i++) {
155155
points[i].display();
156156
}
@@ -176,8 +176,8 @@ We need to find the distance between our mouse pointer and each `Point` in our d
176176

177177
```javascript
178178
function classifyMouse() {
179-
180179
let distances = [];
180+
181181
for (var i = 0; i < points.length; i++) {
182182
// TODO: Find the distance between each point and the mouse.
183183
}
@@ -232,11 +232,13 @@ We now know whether the mouse should be classified as red or green. Let's draw a
232232

233233
```javascript
234234
noStroke();
235+
235236
if (numOne > numZero) {
236237
fill(255, 0, 0);
237238
} else {
238239
fill(0, 255, 0);
239240
}
241+
240242
ellipse(mouseX, mouseY, 10, 10);
241243
```
242244

0 commit comments

Comments
 (0)