Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
6c94a6b
Structuring the page
serhatsumer Oct 11, 2019
4a9f1c6
characters in a string is sorted
serhatsumer Oct 11, 2019
c88ac98
characters in a string are reversed
serhatsumer Oct 11, 2019
db0ef49
vowels from a string are removed
serhatsumer Oct 11, 2019
af612e2
repeted string
serhatsumer Oct 11, 2019
c2b738e
some styling
serhatsumer Oct 11, 2019
3b4f84a
some of module-exercises are done
serhatsumer Oct 11, 2019
941c68b
some exercises
serhatsumer Oct 16, 2019
cb27246
some changes
serhatsumer Oct 16, 2019
2ca6dd5
index and styleshet created
serhatsumer Oct 18, 2019
a6d3093
caesarize.js created
serhatsumer Oct 18, 2019
e129090
constantize crated
serhatsumer Oct 18, 2019
b366d11
leftpad.js created
serhatsumer Oct 18, 2019
055c3cb
repeatChars.js created
serhatsumer Oct 18, 2019
11a31b4
some update
serhatsumer Oct 26, 2019
355f524
upstream/merge
serhatsumer Oct 26, 2019
07b338b
caesarize is done
serhatsumer Oct 26, 2019
b70d970
variables completed
serhatsumer Nov 14, 2019
9260c04
function.js completed
serhatsumer Nov 15, 2019
d4ac732
primitive-types completed
serhatsumer Nov 16, 2019
faad1e8
explicit-coercion completed
serhatsumer Nov 16, 2019
9365cc5
truthiness & truthiness-operators completed
serhatsumer Nov 16, 2019
d09a90d
arrays completed
serhatsumer Nov 17, 2019
6b9cb80
objects & arrays-objects completed
serhatsumer Nov 17, 2019
624ffcd
block-scope completed
serhatsumer Nov 18, 2019
37658e1
conditional-statements completed
serhatsumer Nov 18, 2019
be2f63d
statements-vs-expressions completed
serhatsumer Nov 18, 2019
294854a
loops completed
serhatsumer Nov 18, 2019
51facfb
fixed a few errors
serhatsumer Nov 18, 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
12 changes: 9 additions & 3 deletions module-exercises/arrays-vs-objects.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ try {
let _ = null;

// swap the values stored in each structure

_ = obj.prop;
obj.prop = arr[0];
arr[0] = _;

console.assert(obj.prop === "object", "obj.prop should be 'object");
console.assert(arr[0] === "array", "arr[0] should be 'array");
Expand All @@ -32,11 +34,14 @@ try {
// swap the values stored in each structure using brackets and these variables
const objKey = 'prop';
const arrIndex = 0;
_ = obj[objKey];
obj[objKey] = arr[arrIndex];
arr[arrIndex] = _ ;


// asserts
console.assert(obj[obj_key] === "object", "obj assert");
console.assert(arr[arr_index] === "array", "arr assert");
console.assert(obj[objKey] === "object", "obj assert");
console.assert(arr[arrIndex] === "array", "arr assert");
}
evaluate(swapValues2);

Expand All @@ -54,6 +59,7 @@ try {
const arr2 = [3, 2, 1];
const arr3 = [1, 2, 3];
// do you remember why '===' won't work here?

console.assert(evaluate.compareValues(arr1, arr2), 'arr: same values, different order');
console.assert(evaluate.compareValues(arr1, arr3), 'arr: same values, same order');

Expand Down
32 changes: 16 additions & 16 deletions module-exercises/arrays.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,22 +101,22 @@ try {


function passTheAssertions1() {
; // declare and assign a1
; // declare and assign a2
let a1 = [1]; // 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 = [2]; // declare and assign b1
let b2 = [3]; // 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!"');

; // write two lines to pass the assertions
;
b1[0] = 'bye!'; // write two lines to pass the assertions
b2[0] = b1[0];
console.assert(b1[0] === b2[0], 'b1[0] should strictly equal b2[0]');
console.assert(b1[0] === 'bye!', 'b1.x should strictly equal "bye!"');
}
Expand All @@ -127,16 +127,16 @@ try {
const value1 = 5;
let reference1 = [];

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

; // write this line
reference1[0] = '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!'");

Expand All @@ -151,8 +151,8 @@ try {


function passTheAssertions3() {
; // write this line
; // write this line
let arr1 = ['A','B']; // write this line
let arr2 = ['A','B']; // 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 +161,18 @@ try {
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]] = arr1[1]; // write this line
arr2[arr1[2]] = arr1[arr2[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[0]; // write this line
console.assert(arr3[2] === arr2[index], 'arr3[2] should strictly equal arr2[index]');
}
evaluate(passTheAssertions3);
Expand Down
23 changes: 12 additions & 11 deletions module-exercises/block-scope.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,28 +41,29 @@ try {
const aString = 'inner value';
console.assert(aString === 'inner value', 'aString should be "inner value"');
}

console.assert(aString === 'outer value', 'aString should be "outer value"');

}
evaluate(example_innerVariablesOverrideOuterOnes);


function blockScopeExercise1() {
; // write this line
const a = 'hi!'; // write this line
console.assert(a === 'hi!', 'a should be "hi!"');
{
; // write this line
const a = 'hola!'; // write this line
console.assert(a === 'hola!', 'a should be "hola!"');
}
console.assert(a === 'hi!', 'a should be "hi!"');
}
evaluate(blockScopeExercise1);

function blockScopeExercise2() {
; // write this line
const a = 'hi!'; // write this line
console.assert(a === 'hi!', 'a should be "hi!"');
{
; // write this line
let b = 'hola!'; // write this line
console.assert(b === 'hola!', 'b should be "hola!"');
console.assert(a === 'hi!', 'a should be "hi!"');
}
Expand All @@ -71,39 +72,39 @@ try {
evaluate(blockScopeExercise2);

function blockScopeExercise3() {
; // write this line
const a = 'hi!'; // write this line
console.assert(a === 'hi!', 'a should be "hi!"');
{
; // write this line
let b = 'hola!'; // write this line
console.assert(b === 'hola!', 'b should be "hola!"');
console.assert(a === 'hi!', 'a should be "hi!"');
}
; // write this line
let b = 'hola!'; // write this line
console.assert(b === 'hola!', 'b should be "hola!"');
console.assert(a === 'hi!', 'a should be "hi!"');
}
evaluate(blockScopeExercise3);

function blockScopeExercise4() {
; // write this line
let x = 'null'; // write this line
console.assert(x === 'null', 'x should be "null!"');
{
const a = 5;
const b = 4;
; // write this line
x = a * b ; // write this line
console.assert(x === 20, 'x should be 20');
}
console.assert(x === 20, 'x should be 20');
}
evaluate(blockScopeExercise4);

function blockScopeExercise5() {
; // write this line
let x = 'null'; // write this line
console.assert(x === 'null', 'x should be "null!"');
{
const a = false;
const b = true;
; // write this line
if (x = b ){ x = 20; } // write this line
console.assert(x === 20, 'x should be true');
}
console.assert(x === 20, 'x should be true');
Expand Down
94 changes: 52 additions & 42 deletions module-exercises/conditional-statements.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,15 @@ try {
// 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: 'if 2', args: ['0',0], expected: 'if' },
{ name: 'if 3', args: ['',0], expected: 'if' },
{ name: 'if 4', args: [5, 5], expected: 'if' },
{ name: 'if 5', args: ['2', 2], 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: 'else 2', args: [1, 0], expected: 'else' },
{ name: 'else 3', args: ['9','ll'], expected: 'else' },
{ name: 'else 4', args: ['9',0], expected: 'else' },
{ name: 'else 5', args: [9, 7], expected: 'else' },
];
function conditionalToPass1(a, b) {
if (Number(a) === b) {
Expand All @@ -110,20 +110,20 @@ try {
// 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: ['true','false'], expected: 'if' },
{ name: 'if 3', args: [false, true], expected: 'if' },
{ name: 'if 4', args: [null,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: [false, 1], expected: 'else if' },
{ name: 'else if 3', args: ['true',false], expected: 'else if' },
{ name: 'else if 4', args: ["1",0], expected: 'else if' },
{ name: 'else if 5', args: [true,0], 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: [null,0], expected: 'else' },
{ name: 'else 3', args: ["1",1], expected: 'else' },
{ name: 'else 4', args: ['',NaN], expected: 'else' },
{ name: 'else 5', args: [false,0], expected: 'else' },
];
function conditionalToPass2(a, b) {
if (typeof a === typeof b) {
Expand Down Expand Up @@ -153,7 +153,11 @@ try {
];
// careful of unreachable blocks! are any of yours unreachable?
function passTests1(a, b) {
// conditional an if/else conditional statement to pass these tests
if (Boolean(a) === Boolean(b)) {
return 'if';
}else {
return 'else';
}// conditional an if/else conditional statement to pass these tests
// you can pass the tests using only
// primitive values
// Number, String, Boolean
Expand Down Expand Up @@ -182,7 +186,13 @@ try {
];
// careful of unreachable blocks! are any of yours unreachable?
function passTests2(a, b) {
// conditional an if/elseif/else conditional statement to pass these tests
if ( a === b ) {
return 'if';
} else if ( Number(a) !== Number(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
// Number, String, Boolean
Expand Down Expand Up @@ -221,16 +231,16 @@ try {

const conditionalTests1 = [
// write test cases to pass this function
{ name: 'first', args: null, expected: null },
{ name: 'second', args: null, expected: null },
{ name: 'third', args: null, expected: null },
{ name: 'fourth', args: null, expected: null },
{ name: 'fifth', args: null, expected: null },
{ name: 'sixth', args: null, expected: null },
{ name: 'seventh', args: null, expected: null },
{ name: 'eighth', args: null, expected: null },
{ name: 'ninth', args: null, expected: null },
{ name: 'tenth', args: null, expected: null },
{ name: 'first', args: [true,true], expected: true },
{ name: 'second', args: [1,1], expected: true },
{ name: 'third', args: ["2",1], expected: false },
{ name: 'fourth', args: [true,0], expected: true },
{ name: 'fifth', args: [NaN,NaN], expected: false },
{ name: 'sixth', args: ["1", 1], expected: false },
{ name: 'seventh', args: ["",""], expected: false },
{ name: 'eighth', args: [false, true], expected: true },
{ name: 'ninth', args: [1, 2], expected: true },
{ name: 'tenth', args: ["r", true], expected: false },
];
function conditionalFunction1(a, b) {
let result = null;
Expand All @@ -249,16 +259,16 @@ try {

const conditionalTests2 = [
// write test cases to pass this function
{ name: 'first', args: null, expected: null },
{ name: 'second', args: null, expected: null },
{ name: 'third', args: null, expected: null },
{ name: 'fourth', args: null, expected: null },
{ name: 'fifth', args: null, expected: null },
{ name: 'sixth', args: null, expected: null },
{ name: 'seventh', args: null, expected: null },
{ name: 'eighth', args: null, expected: null },
{ name: 'ninth', args: null, expected: null },
{ name: 'tenth', args: null, expected: null },
{ name: 'first', args: [1,1], expected: 1 },
{ name: 'second', args: [true,false], expected: true },
{ name: 'third', args: [true, 1], expected: false },
{ name: 'fourth', args: [true, 0], expected: false },
{ name: 'fifth', args: [2, 1], expected: 1 },
{ name: 'sixth', args: [false,true], expected: true },
{ name: 'seventh', args: [1, true], expected: false },
{ name: 'eighth', args: ["otur","kalk"], expected: "kalk"},
{ name: 'ninth', args: ["oreo","peanut"], expected: "peanut" },
{ name: 'tenth', args: ["str", 1], expected: null },
];
function conditionalFunction2(a, b) {
let result = null;
Expand Down
Loading