├── Day 1 ├── Day 1-1.js └── Day 1-2.js ├── Day 2 ├── Day 2-1.js └── Day 2-2.js ├── Day 3 ├── Day 3-1.js ├── Day 3-2.js └── Day 3-3.js ├── Day 4 ├── Day 4-1.js ├── Day 4-2.js ├── Day 4-3.js └── Day 4-4.js ├── Day 5 ├── button.css └── index.html ├── Day 6 └── index.html └── Day 7 ├── binaryCalculator.js ├── css └── binaryCalculator.css └── index.html /Day 1/Day 1-1.js: -------------------------------------------------------------------------------- 1 | // complete the function 2 | function vowelsAndConsonants(s) { 3 | 4 | var Arr = s.toLowerCase().split( '' ), 5 | c = '', 6 | vArr = ['a','e','i','o','u'], 7 | vowelsResult = "", 8 | consonantsResult = ""; 9 | 10 | for ( c of Arr ){ 11 | if( vArr.indexOf( c )!==-1 ){ 12 | vowelsResult += c + "\n"; 13 | } 14 | else { 15 | consonantsResult += c + "\n"; 16 | } 17 | } 18 | 19 | console.log(vowelsResult+consonantsResult); 20 | } -------------------------------------------------------------------------------- /Day 1/Day 1-2.js: -------------------------------------------------------------------------------- 1 | var re = /^([aeiou]).*\1$/gi; -------------------------------------------------------------------------------- /Day 2/Day 2-1.js: -------------------------------------------------------------------------------- 1 | function processData(my_string) { 2 | try{ 3 | my_string = my_string.split('').reverse().join(''); 4 | console.log(`Reversed string is : ${my_string}`); 5 | }catch (err){ 6 | console.log(`Error : ${err.message}`); 7 | } finally { 8 | console.log(`Type of my_string is : ${typeof my_string}`); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Day 2/Day 2-2.js: -------------------------------------------------------------------------------- 1 | function processData(my_height) { 2 | try{ 3 | if (isNaN(my_height)) { 4 | throw new Error('notANumberError'); 5 | } else if (my_height > 10) { throw new Error( 'hugeHeightError'); 6 | } else if (my_height < 4) { 7 | throw new Error( 'tinyHeightError'); 8 | } else console.log(my_height); 9 | } catch (err) { console.log(err.message); } 10 | } 11 | 12 | -------------------------------------------------------------------------------- /Day 3/Day 3-1.js: -------------------------------------------------------------------------------- 1 | function Car(name, mileage, max_speed) { 2 | this.name = name; 3 | this.mileage = mileage; 4 | this.max_speed = max_speed; 5 | } 6 | -------------------------------------------------------------------------------- /Day 3/Day 3-2.js: -------------------------------------------------------------------------------- 1 | Square.prototype.isSquare = function(){ if(this.A == this.B && this.A == this.C && this.A == this.D){ console.log(true); }else{ console.log(false); } } 2 | -------------------------------------------------------------------------------- /Day 3/Day 3-3.js: -------------------------------------------------------------------------------- 1 | function Alpha(){} 2 | 3 | Alpha.prototype.isAlpha = function(letter){ 4 | return /^[a-zA-Z]$/.test(letter); 5 | }; 6 | 7 | function Vowel(){} 8 | Vowel.prototype = new Alpha(); 9 | 10 | Vowel.prototype.isVowel = function(letter){ 11 | return /^[aeiuoyAEIOUY]$/.test(letter); 12 | }; 13 | 14 | 15 | function Consonant(){} 16 | Consonant.prototype = new Alpha(); 17 | 18 | Consonant.prototype.isConsonant = function(letter){ 19 | return /^[^aeiouyAEIOUY]$/.test(letter); 20 | } 21 | 22 | -------------------------------------------------------------------------------- /Day 4/Day 4-1.js: -------------------------------------------------------------------------------- 1 | function multiplier(x) { 2 | return function(y){ return x*y; } 3 | } 4 | -------------------------------------------------------------------------------- /Day 4/Day 4-2.js: -------------------------------------------------------------------------------- 1 | processData = (inputArray) => console.log(inputArray.filter(x => x%2 == 0)); 2 | -------------------------------------------------------------------------------- /Day 4/Day 4-3.js: -------------------------------------------------------------------------------- 1 | let accelerationDueToGravity = pressure(m); 2 | let particleMass = accelerationDueToGravity(g); 3 | let particleHeight = particleMass(h); 4 | 5 | let totalPressure = particleHeight; 6 | -------------------------------------------------------------------------------- /Day 4/Day 4-4.js: -------------------------------------------------------------------------------- 1 | var captcha_check = (function(){ 2 | var actual_captcha = Math.floor(Math.random(100)*Math.pow(10, 5)); 3 | 4 | return { 5 | check: function(guess){ 6 | if(guess === actual_captcha){ 7 | console.log("You have written it correctly."); 8 | } else { 9 | console.log("You have written it incorrectly."); 10 | } 11 | } 12 | } 13 | })(); 14 | 15 | 16 | //Do not edit below this line. 17 | var bot = captcha_check.actual_captcha; 18 | captcha_check.check({}); 19 | console.log(bot); 20 | -------------------------------------------------------------------------------- /Day 5/button.css: -------------------------------------------------------------------------------- 1 | #btn { 2 | width: 96px; 3 | height: 48px; 4 | font-size: 24px; 5 | } 6 | -------------------------------------------------------------------------------- /Day 5/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Button 7 | 8 | 9 | 10 | 11 | 12 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Day 6/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Buttons Grid 7 | 18 | 19 | 20 | 21 | 55 |
56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 |
66 | 67 | 68 | -------------------------------------------------------------------------------- /Day 7/binaryCalculator.js: -------------------------------------------------------------------------------- 1 | function createGrid(context) { 2 | var div = document.createElement("div"); 3 | div.id = "res"; 4 | context.appendChild(div); 5 | 6 | div = document.createElement("div"); 7 | div.id = "btns"; 8 | div.className = "btnContainer"; 9 | context.appendChild(div); 10 | var btnId = ["btn0", "btn1", "btnClr", "btnEql", "btnSum", "btnSub", "btnMul", "btnDiv"]; 11 | var btnhtml = [0, 1, "C", "=", "+", "-", "*", "/"]; 12 | var btnFunc = function() { 13 | var text = this.innerHTML; 14 | var out = document.getElementById("res"); 15 | 16 | if (text == "C") { 17 | out.innerHTML = ""; 18 | } else if (text == "=") { 19 | out.innerHTML = compute(out.innerHTML); 20 | } else { 21 | out.innerHTML += text; 22 | } 23 | }; 24 | 25 | var compute = function(text) { 26 | var operand = text.split(/[+-\/\*]/); 27 | console.log(operand); 28 | var operator = text[operand[0].length]; 29 | console.log(operator); 30 | var op1 = parseInt(operand[0], 2); 31 | var op2 = parseInt(operand[1], 2); 32 | console.log(op1, op2); 33 | return eval(op1 + operator + op2).toString(2); 34 | } 35 | 36 | var ctx = document.getElementById("btns"); 37 | for (var i = 0; i < 8; i++) { 38 | var button = document.createElement("button"); 39 | button.id = btnId[i]; 40 | button.className = "btnClass"; 41 | button.innerHTML = btnhtml[i]; 42 | button.addEventListener("click", btnFunc); 43 | ctx.appendChild(button); 44 | } 45 | } 46 | 47 | createGrid(document.body); 48 | -------------------------------------------------------------------------------- /Day 7/css/binaryCalculator.css: -------------------------------------------------------------------------------- 1 | #res { 2 | background-color: lightgray; 3 | width: 81%; 4 | height: 48px; 5 | font-size: 20px; 6 | border-style: solid; 7 | } 8 | 9 | #btns { 10 | width: 90%; 11 | } 12 | 13 | #btn0, #btn1 { 14 | background-color: lightgreen; 15 | color: brown; 16 | } 17 | 18 | #btnClr, #btnEql { 19 | background-color: darkgreen; 20 | color: white; 21 | } 22 | 23 | #btnSum, #btnSub, #btnMul, #btnDiv { 24 | background-color: black; 25 | color: red; 26 | } 27 | 28 | .btnClass { 29 | width: 22%; 30 | height: 36px; 31 | font-size: 18px; 32 | } 33 | -------------------------------------------------------------------------------- /Day 7/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Binary Calculator 7 | 8 | 9 | 10 | 11 | 12 | 13 | --------------------------------------------------------------------------------