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
f18c472
variables exercises completed
Mert1980 Oct 8, 2019
3363890
module exercise variable.js and functions.js files are updated
Mert1980 Oct 8, 2019
a87caf2
style added
Mert1980 Oct 9, 2019
1fe340e
Merge pull request #1 from Mert1980/style
Mert1980 Oct 9, 2019
3dd8716
reversehandler code completed
Mert1980 Oct 9, 2019
b3067d6
Merge pull request #2 from Mert1980/reversehandler
Mert1980 Oct 9, 2019
5aca9bc
style and html files are updated
Mert1980 Oct 9, 2019
d2ea248
repeat-handler.js file completed
Mert1980 Oct 9, 2019
0fb1876
Merge pull request #3 from Mert1980/repeathandler
Mert1980 Oct 9, 2019
41671b8
sorthandler.js code completed
Mert1980 Oct 10, 2019
ee731cf
Merge pull request #4 from Mert1980/sorthandler
Mert1980 Oct 10, 2019
5db4071
devowelhandler.js file codes are completed
Mert1980 Oct 10, 2019
0d8f9d3
Merge pull request #5 from Mert1980/devowelhandler
Mert1980 Oct 10, 2019
5872eca
some style changes added to the index.html and style.css files
Mert1980 Oct 11, 2019
02648ff
font family changed
Mert1980 Oct 11, 2019
5ed6ebe
Update README.md
Mert1980 Oct 11, 2019
2307047
Update README.md
Mert1980 Oct 11, 2019
2934250
Update README.md
Mert1980 Oct 11, 2019
bfc5b39
Update README.md
Mert1980 Oct 11, 2019
4c1ce72
Update README.md
Mert1980 Oct 11, 2019
c06c7e0
Update README.md
Mert1980 Oct 11, 2019
ff4d86b
Update README.md
Mert1980 Oct 11, 2019
eb2f8d0
function module exercises completed
Mert1980 Oct 12, 2019
5e49554
Merge remote-tracking branch 'origin/master'
Mert1980 Oct 12, 2019
eef7c2d
explicit coersion, primitive types and truthiness exercises completed
Mert1980 Oct 13, 2019
de01983
first truthiness operators exercise completed
Mert1980 Oct 15, 2019
9cbaf0c
files updated due to the amendment in project
Mert1980 Oct 15, 2019
b0f9a24
Update README.md
Mert1980 Oct 15, 2019
b95b63a
Update index.html
Mert1980 Oct 15, 2019
87af542
Update leftpad.js
Mert1980 Oct 15, 2019
dae1d20
caesarize.js code completed
Mert1980 Oct 16, 2019
e550c8e
Merge pull request #6 from Mert1980/caesarize
Mert1980 Oct 16, 2019
97a468c
repeatchars.js file is completed
Mert1980 Oct 18, 2019
7128ba9
Merge pull request #7 from Mert1980/repeatChars
Mert1980 Oct 18, 2019
137e62c
I completed the code for constantize. It passed all the tests
Mert1980 Oct 18, 2019
e795f3a
Merge pull request #8 from Mert1980/constantize
Mert1980 Oct 18, 2019
36145f7
style changes applied
Mert1980 Oct 18, 2019
6d9a485
Merge pull request #9 from Mert1980/styleweek2
Mert1980 Oct 18, 2019
db23a60
footer changed
Mert1980 Oct 18, 2019
dbe6704
truthiness operators completed
Mert1980 Oct 19, 2019
f6f8819
Merge pull request #10 from Mert1980/leftpad
Mert1980 Oct 19, 2019
d4e65f1
Update index.html
Mert1980 Oct 19, 2019
ed49b41
primitive operators and arrays module exercises completed
Mert1980 Oct 19, 2019
f53c254
week3 style completed
Mert1980 Oct 22, 2019
f456b1f
Merge pull request #11 from Mert1980/styleweek3
Mert1980 Oct 22, 2019
6981eb3
updated week3 project files
Mert1980 Oct 22, 2019
73ad0b5
Merge remote-tracking branch 'origin/master'
Mert1980 Oct 22, 2019
1abf6b4
corrected files for week2 and week3
Mert1980 Oct 23, 2019
a90cccd
week3 project files are updated
Mert1980 Oct 25, 2019
36afbf3
for loop line 59 to 65 updated
Mert1980 Oct 25, 2019
261a4a0
for, else if loops and test cases updated
Mert1980 Oct 26, 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
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"liveServer.settings.port": 5501
}
3 changes: 3 additions & 0 deletions module-exercises/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## Module Exercises

### Please click the link below to see the my progress in Module Exercises;

<a href="https://mert1980.github.io/javascript-1/module-exercises/">Module Exercises_Mert</a>

In this folder you'll find a lot of files and two folders:
* __[how-to-do-exercises](./how-to-do-exercises)__: Check out this folder for a guide to completing these exercises. Completing these exercises isn't as easy as following FreeCodeCamp or CodeAcademy, but you will learn a whole lot more! You will have an immersive experience working in the Developer Tools. And will be able to study any snippet or function you want instead of being limited to the exercises provided. Taking a look at how ```evaluate``` works before diving into the exercises will make the transition a bit smoother.
Expand Down
64 changes: 37 additions & 27 deletions module-exercises/arrays.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,58 +101,68 @@ evaluate(example_garbageCollectingArrays);


function passTheAssertions1() {
; // declare and assign a1
; // declare and assign a2
console.assert(a1 === a2, 'a1 should strictly equal 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
console.assert(b1 !== b2, 'b1 should not strictly equal 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
console.assert(a1[0] === a2[0], 'a1[0] should strictly equal a2[0]');
console.assert(a1[0] === 'hi!', 'a1.x should strictly equal "hi!"');

; // write two lines to pass the assertions
;
console.assert(b1[0] === b2[0], 'b1[0] should strictly equal b2[0]');
console.assert(b1[0] === 'bye!', 'b1.x should strictly equal "bye!"');
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]");
console.assert(b1[0] === "bye!", 'b1.x should strictly equal "bye!"');
}
evaluate(passTheAssertions1);


function passTheAssertions2() {
const value1 = 5;
let value2 = 5;
const value1 = value2;
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
value2 = "___";
// value2 = value2 + 1; // write this line
console.assert(value1 !== null, "value1 should strictly equal ___");

; // write this line

reference2 = reference1 = ["hi!", "hi!"];
// write this line
console.assert(reference1[0] === reference2[0], "references[0] should be strictly equal");
console.assert(reference1[0] === 'hi!', "reference1[0] should be strictly equal to 'hi!'");

; // write this line

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

// remove the array from memory
; // write this line
; // write this line
reference1 = null; // write this line
reference2 = null; // write this line
}
evaluate(passTheAssertions2);


function passTheAssertions3() {
; // write this line
; // write this line
let arr1=["A","B",1]; // write this line
let arr2=["A","B",1]; // write this line
console.assert(arr1 !== arr2, 'the variables should not be strictly equal');
console.assert(arr1[1] === arr2[1], 'their first entries should be the same');
console.assert(arr1[1] === 'B', 'arr1[1]] should be "B"');
Expand All @@ -161,18 +171,18 @@ function passTheAssertions3() {
console.assert(arr1[index] === arr2[index], 'arr1[index] should strictly equal arr2[index]');
console.assert(arr1[index] === 'A', 'arr1[index] should be "A"');

; // write this line
; // write this line
// arr1[arr2[2]] === "B"; // write this line
arr1[arr2[2]] === arr2[arr1[2]]; // write this line
console.assert(arr1[arr2[2]] === 'B', 'arr2[2] should be "B"s index in arr1');
console.assert(arr1[arr2[2]] === arr2[arr1[2]], 'some tricky nested thing should be true');

; // write this line
let arr3 = arr2; // write this line
console.assert(arr1 !== arr2, 'arr1 should strictly equal arr2');
console.assert(arr3 !== arr1, 'arr3 should not strictly equal arr`');
console.assert(arr3 === arr2, 'arr3 should strictly equal arr2');
console.assert(arr3[index] === arr1[0], 'arr3[index] should strictly equal arr1[0]');

; // write this line
arr3[2] = arr2[index]; // write this line
console.assert(arr3[2] === arr2[index], 'arr3[2] should strictly equal arr2[index]');
}
evaluate(passTheAssertions3);
Expand Down
65 changes: 37 additions & 28 deletions module-exercises/conditional-statements.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ evaluate(example_unreachableCode);
// complete the args array to pass each test case
const conditionalTestCases1 = [
{ name: 'if 1', args: ['5', 5], expected: 'if' },
{ name: 'if 2', args: null, expected: 'if' },
{ name: 'if 3', args: null, expected: 'if' },
{ name: 'if 4', args: null, expected: 'if' },
{ name: 'if 5', args: null, expected: 'if' },
{ name: 'else 1', args: [true, 0], expected: 'else' },
{ name: 'else 2', args: null, expected: 'else' },
{ name: 'else 3', args: null, expected: 'else' },
{ name: 'else 4', args: null, expected: 'else' },
{ name: 'else 5', args: null, expected: 'else' },
{ name: 'if 2', args: ['4', 4], expected: 'if' },
{ name: 'if 3', args: ['3', 3], expected: 'if' },
{ name: 'if 4', args: ['0', 0], expected: 'if' },
{ name: 'if 5', args: ['-1', -1], expected: 'if' },
{ name: 'else 1', args: ['true', 0], expected: 'else' },
{ name: 'else 2', args: ['false', 0], expected: 'else' },
{ name: 'else 3', args: ['NaN', 2], expected: 'else' },
{ name: 'else 4', args: ['null', 0], expected: 'else' },
{ name: 'else 5', args: ['undefined', 0], expected: 'else' },
];
function conditionalToPass1(a, b) {
if (Number(a) === b) {
Expand All @@ -108,20 +108,20 @@ evaluate(conditionalToPass1, conditionalTestCases1);
// complete the args array to pass each test case
const conditionalTestCases2 = [
{ name: 'if 1', args: ['happy', 'day'], expected: 'if' },
{ name: 'if 2', args: null, expected: 'if' },
{ name: 'if 3', args: null, expected: 'if' },
{ name: 'if 4', args: null, expected: 'if' },
{ name: 'if 5', args: null, expected: 'if' },
{ name: 'if 2', args: [0, NaN], expected: 'if' },
{ name: 'if 3', args: ['null', 'null'], expected: 'if' },
{ name: 'if 4', args: ['undefined', 'null'], expected: 'if' },
{ name: 'if 5', args: ['0', '-1'], expected: 'if' },
{ name: 'else if 1', args: [1, ''], expected: 'else if' },
{ name: 'else if 2', args: null, expected: 'else if' },
{ name: 'else if 3', args: null, expected: 'else if' },
{ name: 'else if 4', args: null, expected: 'else if' },
{ name: 'else if 5', args: null, expected: 'else if' },
{ name: 'else if 2', args: [0, 'null'], expected: 'else if' },
{ name: 'else if 3', args: [0, '[]'], expected: 'else if' },
{ name: 'else if 4', args: [0, '[]'], expected: 'else if' },
{ name: 'else if 5', args:[0, '1'], expected: 'else if' },
{ name: 'else 1', args: [true, 1], expected: 'else' },
{ name: 'else 2', args: null, expected: 'else' },
{ name: 'else 3', args: null, expected: 'else' },
{ name: 'else 4', args: null, expected: 'else' },
{ name: 'else 5', args: null, expected: 'else' },
{ name: 'else 2', args: [0, null], expected: 'else' },
{ name: 'else 3', args: [0, undefined], expected: 'else' },
{ name: 'else 4', args: ["true", true], expected: 'else' },
{ name: 'else 5', args: ["1", true], expected: 'else' },
];
function conditionalToPass2(a, b) {
if (typeof a === typeof b) {
Expand Down Expand Up @@ -151,11 +151,11 @@ const testsToPass1 = [
];
// careful of unreachable blocks! are any of yours unreachable?
function passTests1(a, b) {
// conditional an if/else conditional statement to pass these tests
// you can pass the tests using only
// primitive values
// Number, String, Boolean
// typeof, ===, !==
if (Boolean(a) === Boolean(b)) {
return 'if';
} else {
return 'else';
}
}
passTests1.quizzing = true;
evaluate(passTests1, testsToPass1);
Expand All @@ -172,14 +172,23 @@ const testsToPass2 = [
{ name: 'else if 3', args: [4, 5], expected: 'else if' },
{ name: 'else if 4', args: ['true', 'false'], expected: 'else if' },
{ name: 'else if 5', args: [NaN, NaN], expected: 'else if' },
{ name: 'else 1', args: [5, '5'], expected: 'else' },
{ name: 'else 1', args: [5, '5'], egxpected: 'else' },
{ name: 'else 2', args: ['1000', 1000], expected: 'else' },
{ name: 'else 3', args: ['0', 0], expected: 'else' },
{ name: 'else 4', args: [true, 1], expected: 'else' },
{ name: 'else 5', args: [false, '0'], expected: 'else' },
];
// careful of unreachable blocks! are any of yours unreachable?
function passTests2(a, b) {

if (typeof a === typeof b) {
return 'if';
} else if (typeof a !== typeof b) {
return 'else if';
} else {
return 'else';
}

// conditional an if/elseif/else conditional statement to pass these tests
// you can pass the tests using only
// primitive values
Expand Down Expand Up @@ -219,7 +228,7 @@ evaluate(example_blockScopeInConditionals);

const conditionalTests1 = [
// write test cases to pass this function
{ name: 'first', args: null, expected: null },
{ name: 'first', args: ['1', '1'], expected: String },
{ name: 'second', args: null, expected: null },
{ name: 'third', args: null, expected: null },
{ name: 'fourth', args: null, expected: null },
Expand Down
18 changes: 10 additions & 8 deletions module-exercises/errors-and-lifecycle.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function unexpectedToken3() {
evaluate(unexpectedToken3);

function unexpectedToken4() {
const str = "he told me "run!" the horse arrives!";
const str = "he told me \"run!\" the horse arrives!";
}
evaluate(unexpectedToken4);

Expand All @@ -84,21 +84,23 @@ function missingAfterElement1() {
evaluate(missingAfterElement1)

function missingAfterElement1() {
const myArray = [1, 2 3];
const myArray = [1, 2, 3];
}
evaluate(missingAfterElement1)

function missingBeforeformal() {
function getNine {
function getNine (){
const x = 6, y = 3;
return x + y;
}
}
evaluate(missingBeforeformal);

function unEscapedLineBreak() {
const a = 'this is
const a = 'this is\n
two lines';
// const a = `this is
// two lines`;
}
evaluate(unEscapedLineBreak);

Expand All @@ -107,7 +109,7 @@ evaluate(unEscapedLineBreak);
// these are detected at runtime and will throw an error after the page has loaded

function invalidAssignment() {
const x = 1;
let x = 1;
x++;
}
evaluate(invalidAssignment);
Expand Down Expand Up @@ -144,9 +146,9 @@ evaluate(xIsNull);

function bracketIsUndefined() {
const myArray = [
[1, 2, 3]
[4, 5, 6]
[7, 8, 9]
[1, 2, 3],
[4, 5, 6],
[7, 8, 9],
];
}
evaluate(bracketIsUndefined);
Expand Down
38 changes: 20 additions & 18 deletions module-exercises/explicit-coercion.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@


// it is possible to convert values from one type to another
// there are some understandable and learnable (but not always logical) rules to how this happens
// learning explicit type conversions will make many of the tricky bits of JS quite a bit less tricky
// there are some understandable and learnable (but not always logical) rules to
// how this happens
// learning explicit type conversions will make many of the tricky bits of JS quite
// a bit less tricky

// write some passing test cases
// or fix the existing ones!
Expand All @@ -23,12 +25,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 +47,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: 'obj, 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 +70,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
Loading