Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
b348990
Homework Done
maflooty Oct 10, 2019
afda677
Variables Exercises Done
maflooty Oct 11, 2019
d426ccf
Functions Exercises Done
maflooty Oct 11, 2019
835efaa
Update repeat-handler.js
maflooty Oct 11, 2019
51939d0
Coercion done
maflooty Oct 14, 2019
0a69842
truthiness done
maflooty Oct 14, 2019
ee205e9
Create leftpad.js
maflooty Oct 14, 2019
88f0555
Update index.html
maflooty Oct 14, 2019
4ec0c8d
Index
maflooty Oct 16, 2019
ed2f9ca
css
maflooty Oct 16, 2019
b37095e
evaluate
maflooty Oct 16, 2019
39446af
leftpad handle
maflooty Oct 16, 2019
a7fba9e
repeatChars done
maflooty Oct 16, 2019
05b3c82
Constantize done
maflooty Oct 17, 2019
32e34d5
caesarize done
maflooty Oct 17, 2019
8845dd4
repeatChars done
maflooty Oct 18, 2019
38b4007
caesarize done
maflooty Oct 18, 2019
53a7040
Delete constantize.js
maflooty Oct 18, 2019
09834cd
constantize done
maflooty Oct 18, 2019
aef9da6
Create constantize.js
maflooty Oct 18, 2019
0c0c9e1
constantize.js
maflooty Oct 18, 2019
96821b4
constantize.js
maflooty Oct 18, 2019
3143a5f
constantize done
maflooty Oct 18, 2019
ba2624f
Update constantize.js
maflooty Oct 18, 2019
7b65c93
constantize done
maflooty Oct 18, 2019
9d8586c
constantize done
maflooty Oct 18, 2019
853b320
only 5 tests unpassed
maflooty Oct 18, 2019
5da0987
Delete decrypt.js
maflooty Oct 22, 2019
e58f9b0
Create decrypt.js
maflooty Oct 22, 2019
e063dd4
Delete encrypt.js
maflooty Oct 22, 2019
2acf3ff
Create encrypt.js
maflooty Oct 22, 2019
384a17f
Delete scramble.js
maflooty Oct 22, 2019
6c9c51d
Create scramble.js
maflooty Oct 22, 2019
8545a2a
Delete caesarize.js
maflooty Oct 22, 2019
305542b
Create caesarize.js
maflooty Oct 22, 2019
29bcbcc
Delete chunk.js
maflooty Oct 22, 2019
df461dc
Create chunk.js
maflooty Oct 22, 2019
23d37ac
Create reverse-chunk.js
maflooty Oct 22, 2019
651dda2
Delete scramble.js
maflooty Oct 22, 2019
8a3ff0c
Create scramble.js
maflooty Oct 22, 2019
1cedc6b
Delete backward-sentence.js
maflooty Oct 22, 2019
3356f68
Update index.html
maflooty Oct 22, 2019
f417725
caesarized done
maflooty Oct 23, 2019
6939ac0
index modified
maflooty Oct 23, 2019
d9285e0
evaluate.js added
maflooty Oct 23, 2019
5fde8d7
style.css added
maflooty Oct 23, 2019
f7c998f
Updated
maflooty Oct 24, 2019
7414e4f
Primitive Operator done
maflooty Oct 24, 2019
ab82b63
sort-words added
maflooty Oct 25, 2019
3941a23
updated
maflooty Oct 25, 2019
5eebc38
JS Week-1-Project
maflooty Nov 3, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions module-exercises/arrays.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,20 +101,21 @@ evaluate(example_garbageCollectingArrays);


function passTheAssertions1() {
; // declare and assign a1
; // declare and assign a2
let a1 = []; // declare and assign a1
let a2 = a1 ; // declare and assign a2
console.assert(a1 === a2, 'a1 should strictly equal a2');

; // declare and assign b1
; // declare and assign b2
let b1 = ["b"] ; // declare and assign b1
let b2 = ["b"]; // declare and assign b2
console.assert(b1 !== b2, 'b1 should not strictly equal b2');

// ---

; // write one line to pass the assertions
a1[0] = "hi!" ; // write one line to pass the assertions
console.assert(a1[0] === a2[0], 'a1[0] should strictly equal a2[0]');
console.assert(a1[0] === 'hi!', 'a1.x should strictly equal "hi!"');

b1 = b2 = ['"bye!"', '"bye!"'];
b1[0] = "bye!";
; // write two lines to pass the assertions
;
console.assert(b1[0] === b2[0], 'b1[0] should strictly equal b2[0]');
Expand All @@ -125,12 +126,12 @@ evaluate(passTheAssertions1);

function passTheAssertions2() {
const value1 = 5;
let reference1 = [];


; // write this line
console.assert(value2 === value1, "value1 should strictly equal value2");

; // write this line
let reference2 = reference1;// write this line
console.assert(reference2 === reference1, "reference1 should strictly equal reference2");

value2 = value2 + 1; // write this line
Expand Down
2 changes: 0 additions & 2 deletions module-exercises/conditional-statements.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// https://www.youtube.com/watch?v=9O-PCTfT6Rs&list=PLzV58Zm8FuBJFfQN5il3ujx6FDAY8Ds3u&index=3

{
const pageTitle = 'conditional statements';
const header = document.createElement("h2");
Expand Down
4 changes: 2 additions & 2 deletions module-exercises/errors-and-lifecycle.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ this way you can come back later to study the errors and solutions
// --- syntax errors ---
// these are detected at creation phase and will stop the page from loading

function missingVariableName() {
/*function missingVariableName() {
const = null;
}
evaluate(missingVariableName);
Expand Down Expand Up @@ -102,7 +102,7 @@ function unEscapedLineBreak() {
}
evaluate(unEscapedLineBreak);


*/
// --- semantic errors ---
// these are detected at runtime and will throw an error after the page has loaded

Expand Down
32 changes: 16 additions & 16 deletions module-exercises/explicit-coercion.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
// fix the test cases' expected values to pass the function
const StringTests = [
// string values remain unchanged
{ name: 'str, any string', args: ['any string'], expected: null },
{ name: 'str, any string', args: ['any string'], expected: "any string" },
// casting with String just puts quotes around a thing
{ name: 'num, 3', args: [3], expected: null },
{ name: 'boo, true', args: [true], expected: null },
{ name: 'obj, null', args: [null], expected: null },
{ name: 'und, undefined', args: [undefined], expected: null },
{ name: 'num, 3', args: [3], expected: "3" },
{ name: 'boo, true', args: [true], expected: "true" },
{ name: 'obj, null', args: [null], expected: "null" },
{ name: 'und, undefined', args: [undefined], expected: "undefined" },
// write at least 5 more test cases for the String function
];
String.quizzing = true;
Expand All @@ -45,11 +45,11 @@ const NumberTests = [
{ name: 'num, Infinity', args: [Infinity], expected: Infinity },
{ name: 'num, NaN', args: [NaN], expected: NaN },
// true and false, the only boolean values
{ name: 'boo, true', args: [true], expected: 0 },
{ name: 'boo, false', args: [false], expected: 1 },
{ name: 'boo, true', args: [true], expected: 1 },
{ name: 'boo, false', args: [false], expected: 0 },
// null & undefined
{ name: 'obj, null', args: [null], expected: NaN },
{ name: 'und, undefined', args: [undefined], expected: 0 },
{ name: 'num, null', args: [null], expected: 0 },
{ name: 'und, undefined', args: [undefined], expected: NaN },
// strings are bit more interesting, write 7 more test cases with string args
{ name: 'str, undefined', args: ['undefined'], expected: NaN },
{ name: 'str, Infinity', args: ['Infinity'], expected: Infinity },
Expand All @@ -68,19 +68,19 @@ const BooleanTests = [
{ name: 'boo, false', args: [false], expected: false },
// anything but 0 & NaN is cast to true
{ name: 'num, 3', args: [3], expected: true },
{ name: 'num, 0', args: [0], expected: true },
{ name: 'num, 0', args: [0], expected: false },
{ name: 'num, 1e3', args: [1000], expected: true },
{ name: 'num, Infinity', args: [Infinity], expected: false },
{ name: 'num, Infinity', args: [Infinity], expected: true },
{ name: 'num, NaN', args: [NaN], expected: false },
// null & undefined
{ name: 'obj, null', args: [null], expected: true },
{ name: 'und, undefined', args: [undefined], expected: true },
{ name: 'obj, null', args: [null], expected: false },
{ name: 'und, undefined', args: [undefined], expected: false },
// anything but an empty string is cast to true
{ name: 'str, undefined', args: ['undefined'], expected: false },
{ name: 'str, false', args: ['false'], expected: false },
{ name: 'str, undefined', args: ['undefined'], expected: true },
{ name: 'str, false', args: ['false'], expected: true },
{ name: 'str, Infinity', args: ['Infinity'], expected: true },
{ name: 'str, three', args: ['three'], expected: true },
{ name: 'str, ', args: [''], expected: true },
{ name: 'str, ', args: [''], expected: false },
{ name: 'str, 3', args: ['3'], expected: true },
];
Boolean.quizzing = true;
Expand Down
2 changes: 0 additions & 2 deletions module-exercises/for-in-for-of.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...in
// https://javascript.info/array#loops
// https://javascript.info/object#the-for-in-loop
// https://alligator.io/js/for-of-for-in-loops/

{
Expand Down
41 changes: 21 additions & 20 deletions module-exercises/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,11 @@ function tracing1() {
};

// set values in the args to pass the assert
let arg1 = "", arg2 = "", arg3 = "";
let arg1 = "y", arg2 = "x", arg3 = "z";
let returnval = f(arg1, arg2, arg3);
console.assert(returnval === "zyx", "1 a");

arg1 = "", arg2 = "", arg3 = "";
arg1 = "z", arg2 = "x", arg3 = "y";
returnval = f(arg1, arg2, arg3);
console.assert(returnval === "yzx", "1 b");

Expand All @@ -194,11 +194,11 @@ function tracing2() {
};

// set values in the args to pass the assert
let arg1 = "", arg2 = "", arg3 = "";
let arg1 = "x", arg2 = "y", arg3 = "z";
let returnVal = f(arg1, arg3, arg2);
console.assert(returnVal === "yxz", "returnVal should be yxz");

arg1 = "", arg2 = "", arg3 = "";
arg1 = "x", arg2 = "z", arg3 = "y";
returnVal = f(arg2, arg1, arg3);
console.log(returnVal === "zxy", "returnVal should be zxy");

Expand All @@ -217,12 +217,12 @@ function tracing3() {
};

// set values in the args to pass the assert
let arg1 = "", arg2 = "", arg3 = "";
let arg1 = "z", arg2 = "x", arg3 = "y";
let returnVal = f(arg1, arg2, arg3);
console.assert(returnVal === "yxz", "returnVal should be yxz");


arg1 = "", arg2 = "", arg3 = "";
arg1 = "z", arg2 = "y", arg3 = "x";
returnVal = f(arg3, arg2, arg1);
console.assert(returnVal === "zyx", "returnVal should be zyx");

Expand All @@ -239,11 +239,11 @@ function tracing4() {
// pass x, y and z to the function in the right order
// don't change their values!
let x = "x", y = "y", z = "z";
let returnVal = f();
let returnVal = f(x,z,y);
console.assert(returnVal === "yxz", "returnVal should be yxz");

x = "x", y = "z", z = "y";
returnVal = f();
returnVal = f(z,x,y);
console.assert(returnVal === "zyx", "returnVal should be zyx");

}
Expand All @@ -260,11 +260,11 @@ function tracing5() {
// pass x, y and z to the function in the right order
// don't change their values!
let x = "x", y = "y", z = "z";
let returnVal = f();
let returnVal = f(z,x,y);
console.assert(returnVal === "xzy", "returnVal should be xzy");

x = "y", y = "x", z = "z";
returnVal = f();
returnVal = f(x,z,y);
console.assert(returnVal === "zyx", "returnVal should be zyx");

}
Expand All @@ -275,7 +275,7 @@ function tracing6() {

// concatinate the params to pass the tests
function f(param1, param2, param3) {
const result = null;
const result = param3 + param1 + param2;
return result;
};

Expand All @@ -295,7 +295,7 @@ function tracing7() {

// concatinate the params to pass the tests
function f(param1, param2, param3) {
const result = null;
const result = param2 + param3 + param1;
return result;
};

Expand All @@ -314,8 +314,8 @@ evaluate(tracing7);
function tracing8() {

// arrange the parameters to pass the asserts
function f() {
var result = param2 + param1 + param3;
function f(param1,param2,param3) {
var result = param2 + param3 + param1;
return result;
};

Expand All @@ -334,8 +334,8 @@ evaluate(tracing8);
function tracing9() {

// arrange the parameters to pass the asserts
function f() {
var result = param1 + param2 + param3;
function f(param1,param2,param3) {
var result = param3 + param1 + param2;
return result;
};

Expand All @@ -354,21 +354,21 @@ evaluate(tracing9);
function tracing10() {

// do what needs to be done!
function f() { // <--
function f(param1,param2,param3,param4) { // <--
var result = param3 + param1 + param2 + param4;
return result;
};

let arg1 = "", arg2 = "", arg3 = "", arg4 = ""; // <--
let arg1 = "y", arg2 = "z", arg3 = "x", arg4 = "w"; // <--
let returnVal = f(arg1, arg2, arg3, arg4);
console.assert(returnVal === "xyzw", "returnVal should be xyzw");

arg1 = "z", arg2 = "w", arg3 = "y", arg4 = "x";
returnVal = f(arg3, arg1, arg4, arg2);
console.assert(returnVal === "", "returnVal should be ?"); // <--
console.assert(returnVal === "xyzw", "returnVal should be xyzw?"); // <--

arg1 = "z", arg2 = "w", arg3 = "y", arg4 = "x";
returnVal = f(); // <--
returnVal = f(arg3,arg2,arg1,arg4); // <--
console.assert(returnVal === "zywx", "returnVal should be zywx");

}
Expand Down Expand Up @@ -398,6 +398,7 @@ function example1_testCases() {
const result = a + b;
return result;
}


testCases.forEach(test => {
const name = test.name;
Expand Down
4 changes: 2 additions & 2 deletions module-exercises/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<script src="variables.js"></script>
<script src="functions.js"></script>
<script src="primitive-types.js"></script>
<script src="explicit-coercion.js"></script>
<script src="explicit-coercion.js"></script>
<script src="truthiness.js"></script>
<script src="truthiness-operators.js"></script>
<script src="primitive-operators.js"></script>
Expand All @@ -39,7 +39,7 @@


<a href="./challenges/index.html">challenge exercises</a>

</body>

</html>
18 changes: 9 additions & 9 deletions module-exercises/primitive-operators.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ const plusTests = [
{ name: 'number, boolean', args: [1, true], expected: 2 },
{ name: 'number, null', args: [1, null], expected: 1 },
{ name: 'number, undefined', args: [1, undefined], expected: NaN },
{ name: 'NaN, anything else', args: [NaN, 'anything else!'], expected: NaN },
{ name: 'NaN, ', args: [NaN, ], expected: NaN },
// fill in the rest of these test cases
{ name: null, args: null, expected: null },
{ name: null, args: null, expected: null },
{ name: null, args: null, expected: null },
{ name: null, args: null, expected: null },
{ name: null, args: null, expected: null },
{ name: null, args: null, expected: null },
{ name: null, args: null, expected: null },
{ name: null, args: null, expected: null },
{ name: 'string,number', args: ['mus',1], expected: 'mus1' },
{ name: 'number,number', args: [2,1], expected: 3 },
{ name: 'number,string', args: [1,'hi'], expected: '1hi' },
{ name: 'null,string', args: [null,'hi'], expected: 'nullhi' },
{ name: 'null,number', args: [null,1], expected: 1 },
{ name: 'string,boolean', args: ['hi',true], expected: 'hitrue' },
{ name: 'boolean,string', args: [false,'hi'], expected: 'falsehi' },
{ name: 'string,string', args: ['hi','hello'], expected: 'hihello' },
];
function plus(a, b) {
return a + b;
Expand Down
Loading