Skip to content
This repository was archived by the owner on Oct 26, 2020. It is now read-only.

Commit 28e5f3d

Browse files
authored
new files
updated files
1 parent 1a4bdd0 commit 28e5f3d

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed

2-reading-list.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Reading List
2+
3+
To challenge yourself even further, you can get ahead for next week's class by reading some of the below documentation:
4+
5+
- [ ] Arrow functions: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions
6+
- [ ] Anonymous vs named functions: https://blog.scottlogic.com/2011/06/10/javascript-anonymous-functions.html
7+
- [ ] Different ways of creating functions: https://www.w3schools.com/js/js_function_definition.asp
8+
- [ ] Introduction to object literals: http://dyn-web.com/tutorials/object-literal/
9+
- [ ] Explanation of callbacks: https://codeburst.io/javascript-what-the-heck-is-a-callback-aba4da2deced

3-sorting-algorithm.js

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*
2+
At the start of the course, you worked in teams to sort your team members, labelled by
3+
numbers, in ascending or descending order.
4+
5+
Today, you will be applying the sorting algorithm you used in that exercise in code!
6+
7+
Create a function called sortAges which:
8+
- takes an array of mixed data types as input
9+
- removes any non-number data types without using the built-in javascript filter method
10+
- returns an array of sorted ages in ascending order
11+
- HARD MODE - without using the built-in javascript sort method 😎
12+
13+
You don't have to worry about making this algorithm work fast! The idea is to get you to
14+
"think" like a computer and practice your knowledge of basic JavaScript.
15+
*/
16+
17+
function sortAges(arr) {}
18+
19+
/* ======= TESTS - DO NOT MODIFY ===== */
20+
21+
const agesCase1 = [
22+
"🎹",
23+
100,
24+
"💩",
25+
55,
26+
"🥵",
27+
"🙈",
28+
45,
29+
"🍕",
30+
"Sanyia",
31+
66,
32+
"James",
33+
23,
34+
"🎖",
35+
"Ismeal",
36+
];
37+
const agesCase2 = ["28", 100, 60, 55, "75", "🍕", "Elamin"];
38+
39+
function arraysEqual(a, b) {
40+
if (a === b) return true;
41+
if (a == null || b == null) return false;
42+
if (a.length != b.length) return false;
43+
44+
for (let i = 0; i < a.length; ++i) {
45+
if (a[i] !== b[i]) return false;
46+
}
47+
48+
return true;
49+
}
50+
51+
function test(test_name, expr) {
52+
let status;
53+
if (expr) {
54+
status = "PASSED";
55+
} else {
56+
status = "FAILED";
57+
}
58+
59+
console.log(`${test_name}: ${status}`);
60+
}
61+
62+
test(
63+
"sortAges function works - case 1",
64+
arraysEqual(sortAges(agesCase1), [23, 45, 55, 66, 100])
65+
);
66+
67+
test(
68+
"sortAges function works - case 2",
69+
arraysEqual(sortAges(agesCase2), [55, 60, 100])
70+
);

0 commit comments

Comments
 (0)