├── Async ├── index.html └── script.js ├── City Stats ├── index.html ├── script.js └── style.css ├── ColorFlipper ├── app.js ├── index.html └── style.css ├── Currency Converter ├── app.js ├── index.html └── style.css ├── Digital Clock ├── index.html ├── script.js └── style.css ├── Error Handling ├── index.html └── script.js ├── FD rate calculator ├── index.html └── style.css ├── Form Validation ├── app.js ├── index.html └── style.css ├── Functions ├── index.html └── script.js ├── If Else ├── index.html └── script.js ├── Image Slider ├── Imgs │ ├── 1.jpg │ ├── 2.jpg │ ├── 3.jpg │ └── 4.jpg ├── app.js ├── index.html └── style.css ├── Introduction ├── index.html ├── script.js └── style.css ├── JSON,API ├── index.html └── script.js ├── LengthConverter ├── index.html └── style.css ├── Loops ├── index.html └── script.js ├── Memory Game ├── index.html ├── mem.js └── style.css ├── Navbar ├── bg.jpg ├── index.html └── style.css ├── OOP ├── car.js ├── index.html └── script.js ├── Objects ├── index.html └── script.js ├── Promise async await ├── index.html └── script.js ├── README.md ├── Set and Map ├── index.html └── script.js ├── Snake ├── app.js ├── index.html └── style.css └── todo ├── app.js ├── index.html └── style.css /Async/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Asynchronous JS 8 | 9 | 10 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Async/script.js: -------------------------------------------------------------------------------- 1 | console.log('Hello..')//f1 2 | function sync(){ 3 | console.log('step 1')//f3 4 | console.log('step 2')//f4 5 | console.log('step 3')//f5 6 | } 7 | sync()//f2 8 | let a = 100 9 | let b=20 10 | let c=a+b 11 | 12 | setTimeout(()=>console.log('step1'),0000)//f6 13 | setTimeout(()=>console.log('step2'),2000)//f7 14 | setTimeout(()=>console.log('step3'),1000)//f8 15 | 16 | console.log('bye')//f9 17 | 18 | //setInterval(()=>console.log("Hi.."),2000) 19 | 20 | 21 | -------------------------------------------------------------------------------- /City Stats/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | City Stats 9 | 10 | 11 |
12 |

Select a city

13 |
14 | 20 |
21 |
22 | 23 |
24 | 25 | 26 |
27 | 30 | 31 | -------------------------------------------------------------------------------- /City Stats/script.js: -------------------------------------------------------------------------------- 1 | /* 2 | 'Chennai': population = 4646732 3 | literacyRate = 90.20 4 | language = 'Tamil' 5 | 'Bengaluru':population = 8443675 6 | literacyRate = 88.71 7 | language = 'Kannada' 8 | 'Mumbai':population = 12442373 9 | literacyRate = 89.73 10 | language = 'Marathi' 11 | 'Delhi': population = 16787941 12 | literacyRate = 86.20 13 | language = 'Hindi' 14 | The Indian city of Bengaluru has a population of 8443675. Language spoken is Kannada and literacy rate is 88.71%. 15 | */ 16 | 17 | const button = document.querySelector('button') 18 | let resultdiv = document.createElement('div') 19 | resultdiv.id = 'result' 20 | document.getElementById('wrapper').appendChild(resultdiv) 21 | 22 | //event listener 23 | button.addEventListener('click',displayStats) 24 | function displayStats(){ 25 | 26 | const input = document.getElementById("input") 27 | const city = input.options[input.selectedIndex].value 28 | let population = 0, literacyRate = 0, language ='' 29 | switch(city){ 30 | case 'Bengaluru': 31 | population = 8443675 32 | literacyRate = 88.71 33 | language = 'Kannada' 34 | break 35 | case 'Chennai': 36 | population = 4646732 37 | literacyRate = 90.20 38 | language = 'Tamil' 39 | break 40 | case 'Mumbai': 41 | population = 12442373 42 | literacyRate = 89.73 43 | language = 'Marathi' 44 | break 45 | case 'Delhi': 46 | population = 16787941 47 | literacyRate = 86.20 48 | language = 'Hindi' 49 | break 50 | 51 | } 52 | let text = `The Indian city of ${city} has a population of ${population}. Language spoken is ${language} and literacy rate is ${literacyRate}%.` 53 | console.log(text) 54 | 55 | document.getElementById('result').innerHTML = text 56 | 57 | } 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /City Stats/style.css: -------------------------------------------------------------------------------- 1 | html, 2 | body{ 3 | margin: 0; 4 | font-family: 'Poppins', sans-serif; 5 | background-color:#f5e8ba; 6 | } 7 | 8 | #wrapper div,#wrapper h2{ 9 | display:flex; 10 | justify-content: center; 11 | 12 | } 13 | 14 | select{ 15 | border-radius: 5px; 16 | border: 2px solid black ; 17 | margin-top:30px; 18 | height:2.5em; 19 | width:250px; 20 | padding-left:10px; 21 | 22 | } 23 | 24 | 25 | h2{ 26 | color:#ffeba7; 27 | letter-spacing: 1px; 28 | } 29 | input{ 30 | border-radius: 5px; 31 | border: 2px solid black ; 32 | margin-top:30px; 33 | height:2em; 34 | width:250px; 35 | padding-left:10px; 36 | } 37 | 38 | input:active{ 39 | border:none; 40 | } 41 | #wrapper{ 42 | height:500px; 43 | width:400px; 44 | margin:200px auto; 45 | background-color:#1f2029; 46 | border-radius:10px; 47 | padding:30px; 48 | } 49 | 50 | button{ 51 | margin-top:20px; 52 | background-color:#ffeba7; 53 | border-radius: 4px; 54 | height: 44px; 55 | font-weight: 600; 56 | padding: 0 30px; 57 | letter-spacing: 1px; 58 | border: none; 59 | background-color: #ffeba7; 60 | color: #102770; 61 | } 62 | 63 | button:hover{ 64 | cursor:pointer; 65 | } 66 | #result{ 67 | color:white; 68 | margin-top:20px; 69 | font-size:32px; 70 | } 71 | 72 | -------------------------------------------------------------------------------- /ColorFlipper/app.js: -------------------------------------------------------------------------------- 1 | const btn = document.getElementById("btn") 2 | const colortext = document.getElementById("color") 3 | const wrap = document.getElementById("wrap") 4 | const hex = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 'A', 'B', 'C', 'D', 'E', 'F'] 5 | 6 | btn.addEventListener('click',function(){ 7 | let hexColor = '#' 8 | for(let i=1;i<=6;i++){ 9 | hexColor += randHexValue() 10 | } 11 | wrap.style.backgroundColor = hexColor 12 | colortext.innerHTML = hexColor 13 | }) 14 | 15 | function randHexValue(){ 16 | let randomIndex = Math.floor(Math.random()*16) 17 | return hex[randomIndex] 18 | } -------------------------------------------------------------------------------- /ColorFlipper/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Document 9 | 10 | 11 |
Color Flipper 12 | #FFFFFF 13 |
14 | 15 |
16 |
17 | 18 |
19 |
20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /ColorFlipper/style.css: -------------------------------------------------------------------------------- 1 | html, 2 | body{ 3 | margin: 0; 4 | font-family: 'Apple Chancery', cursive; 5 | } 6 | #heading{ 7 | text-align: left; 8 | margin-bottom: 0px; 9 | font-size: 2em; 10 | margin-top: 5px; 11 | margin-bottom: 5px; 12 | margin-left: 15px; 13 | color:crimson 14 | } 15 | #color{ 16 | float: right; 17 | margin-right: 15px; 18 | } 19 | 20 | #wrap{ 21 | height:90vh; 22 | width:100vw; 23 | border-top:3px solid #323232; 24 | display:flex; 25 | align-items: center; 26 | justify-content: center; 27 | } 28 | 29 | 30 | button{ 31 | border: 1px solid black; 32 | background-color: rgb(219, 54, 54); 33 | color:white; 34 | border-radius: 15px; 35 | padding: 20px 80px; 36 | font-size: 28px; 37 | letter-spacing: 5px; 38 | cursor:pointer; 39 | } 40 | 41 | -------------------------------------------------------------------------------- /Currency Converter/app.js: -------------------------------------------------------------------------------- 1 | let select = document.querySelectorAll('.currency') 2 | let btn = document.getElementById('btn') 3 | let input = document.getElementById('input') 4 | fetch('https://api.frankfurter.app/currencies') 5 | .then(res=>res.json()) 6 | .then(res=>displayDropDown(res)) 7 | 8 | function displayDropDown(res){ 9 | //console.log(Object.entries(res)[2][0]) 10 | let curr = Object.entries(res) 11 | for(let i=0;i${curr[i][0]}` 13 | select[0].innerHTML += opt 14 | select[1].innerHTML += opt 15 | } 16 | } 17 | 18 | btn.addEventListener('click',()=>{ 19 | let curr1 = select[0].value 20 | let curr2 = select[1].value 21 | let inputVal = input.value 22 | if(curr1===curr2) 23 | alert("Choose different currencies") 24 | else 25 | convert(curr1,curr2,inputVal) 26 | }); 27 | 28 | function convert(curr1,curr2,inputVal){ 29 | const host = 'api.frankfurter.app'; 30 | fetch(`https://${host}/latest?amount=${inputVal}&from=${curr1}&to=${curr2}`) 31 | .then(resp => resp.json()) 32 | .then((data) => { 33 | document.getElementById('result').value = Object.values(data.rates)[0] 34 | }); 35 | 36 | } -------------------------------------------------------------------------------- /Currency Converter/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Currency Convertor 9 | 10 | 11 |
12 |

Currency Convertor

13 |
14 |
15 | 18 | 19 |
20 |
21 | 22 | 23 |
24 |
25 |
26 | 27 |
28 | 29 |
30 | 31 | 32 | -------------------------------------------------------------------------------- /Currency Converter/style.css: -------------------------------------------------------------------------------- 1 | html, 2 | body{ 3 | font-family: 'Poppins', sans-serif; 4 | background-color:#f5e8ba; 5 | margin: 0; 6 | padding: 0; 7 | box-sizing: border-box; 8 | } 9 | 10 | body{ 11 | height: 100vh; 12 | display: flex; 13 | align-items: center; 14 | justify-content: center; 15 | } 16 | 17 | .container{ 18 | background-color:#1f2029; 19 | padding: 10px 24px; 20 | border-radius: 20px; 21 | width: 490px; 22 | } 23 | 24 | h1{ 25 | color:#ffeba7; 26 | text-align: center; 27 | margin-bottom: 0.5em; 28 | font-family: sans-serif; 29 | } 30 | .container .box{ 31 | width: 100%; 32 | display: flex; 33 | } 34 | .box div{ 35 | width: 100%; 36 | } 37 | 38 | select{ 39 | width: 95%; 40 | height: 40px; 41 | font-size: 1.2em; 42 | cursor: pointer; 43 | background-color:coral; 44 | outline: none; 45 | color: black; 46 | margin: 0.2em 0; 47 | padding: 0 1em; 48 | border-radius: 10px; 49 | border: none; 50 | } 51 | 52 | 53 | input{ 54 | width: 80%; 55 | height: 40px; 56 | font-size: 1em; 57 | margin: 0.2em 0; 58 | border-radius: 10px; 59 | border: none; 60 | background: #cccccc; 61 | outline: none; 62 | padding: 0 1em; 63 | } 64 | 65 | .btn{ 66 | display:flex; 67 | justify-content: center; 68 | } 69 | 70 | button{ 71 | width: 50%; 72 | height: 40px; 73 | background-color:#ffeba7; 74 | color: #102770; 75 | border-radius: 10px; 76 | border: none; 77 | cursor: pointer; 78 | font-size: 1em; 79 | margin: 0.5em 0; 80 | 81 | } -------------------------------------------------------------------------------- /Digital Clock/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Digital Clock 9 | 10 | 11 |
12 |
13 | 00 14 | : 15 | 00 16 | : 17 | 00 18 | AM 19 |
20 |
21 | 24 | 25 | -------------------------------------------------------------------------------- /Digital Clock/script.js: -------------------------------------------------------------------------------- 1 | let ampm = document.getElementById('ampm') 2 | function displayTime(){ 3 | let dateTime = new Date(); 4 | let hr = dateTime.getHours(); 5 | let min = padZero(dateTime.getMinutes()); 6 | let sec = padZero(dateTime.getSeconds()); 7 | if(hr>12){ 8 | hr = hr - 12 9 | ampm.innerHTML = 'PM' 10 | } 11 | 12 | document.getElementById('hours').innerHTML = padZero(hr) 13 | document.getElementById('mins').innerHTML = min 14 | document.getElementById('seconds').innerHTML = sec 15 | } 16 | 17 | function padZero(num){ 18 | return num<10?"0"+num:num 19 | } 20 | 21 | setInterval(displayTime,500) -------------------------------------------------------------------------------- /Digital Clock/style.css: -------------------------------------------------------------------------------- 1 | body{ 2 | margin:0; 3 | padding:0; 4 | background: rgb(2,0,36); 5 | background: linear-gradient(90deg, rgba(2,0,36,1) 0%, rgba(9,98,121,1) 35%, rgba(0,212,255,1) 100%); 6 | } 7 | 8 | .container{ 9 | font-family:'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif; 10 | color:white; 11 | display:flex; 12 | width:100vw; 13 | height:100vh; 14 | align-items: center; 15 | justify-content: center; 16 | font-size: 5rem; 17 | } 18 | 19 | #wrapper{ 20 | border: 3px solid white; 21 | padding:1rem; 22 | } 23 | 24 | .container span{ 25 | margin-left:10px; 26 | } 27 | 28 | #ampm{ 29 | font-size:3rem; 30 | align-items: end; 31 | } -------------------------------------------------------------------------------- /Error Handling/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Error Handling 8 | 9 | 10 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Error Handling/script.js: -------------------------------------------------------------------------------- 1 | //Exception Handling 2 | 3 | try{ 4 | num = prompt("Enter a number") 5 | if(num==='') 6 | throw 'Cannot be empty' 7 | if(isNaN(num)) 8 | throw "Enter a valid Number" 9 | console.log(num**2) 10 | } 11 | catch(error){ 12 | console.log(error) 13 | } 14 | finally{ 15 | console.log('bye') 16 | } 17 | -------------------------------------------------------------------------------- /FD rate calculator/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | FD Rate Calculator 9 | 10 | 11 |
12 |

FD Rate Calculator

13 |
14 | 15 |
16 |
17 | 18 |
19 |
20 | 21 |
22 |
23 | 46 | 47 | -------------------------------------------------------------------------------- /FD rate calculator/style.css: -------------------------------------------------------------------------------- 1 | html, 2 | body{ 3 | margin: 0; 4 | font-family: 'Poppins', sans-serif; 5 | background-color:#f5e8ba; 6 | } 7 | 8 | #wrapper div,#wrapper h2{ 9 | display:flex; 10 | justify-content: center; 11 | 12 | } 13 | 14 | h2{ 15 | color:#ffeba7; 16 | letter-spacing: 1px; 17 | } 18 | input{ 19 | border-radius: 5px; 20 | border: 2px solid black ; 21 | margin-top:30px; 22 | height:2em; 23 | width:250px; 24 | padding-left:10px; 25 | } 26 | 27 | input:active{ 28 | border:none; 29 | } 30 | #wrapper{ 31 | height:500px; 32 | width:400px; 33 | margin:200px auto; 34 | background-color:#1f2029; 35 | border-radius:10px; 36 | padding:30px; 37 | } 38 | 39 | button{ 40 | margin-top:20px; 41 | background-color:#ffeba7; 42 | border-radius: 4px; 43 | height: 44px; 44 | font-weight: 600; 45 | padding: 0 30px; 46 | letter-spacing: 1px; 47 | border: none; 48 | background-color: #ffeba7; 49 | color: #102770; 50 | } 51 | 52 | button:hover{ 53 | cursor:pointer; 54 | } 55 | #result{ 56 | color:white; 57 | margin-top:20px; 58 | font-size:32px; 59 | } 60 | 61 | -------------------------------------------------------------------------------- /Form Validation/app.js: -------------------------------------------------------------------------------- 1 | const form = document.querySelector('#form') 2 | const username = document.querySelector('#username'); 3 | const email = document.querySelector('#email'); 4 | const password = document.querySelector('#password'); 5 | const cpassword = document.querySelector('#cpassword'); 6 | 7 | form.addEventListener('submit',(e)=>{ 8 | 9 | if(!validateInputs()){ 10 | e.preventDefault(); 11 | } 12 | }) 13 | 14 | function validateInputs(){ 15 | const usernameVal = username.value.trim() 16 | const emailVal = email.value.trim(); 17 | const passwordVal = password.value.trim(); 18 | const cpasswordVal = cpassword.value.trim(); 19 | let success = true 20 | 21 | if(usernameVal===''){ 22 | success=false; 23 | setError(username,'Username is required') 24 | } 25 | else{ 26 | setSuccess(username) 27 | } 28 | 29 | if(emailVal===''){ 30 | success = false; 31 | setError(email,'Email is required') 32 | } 33 | else if(!validateEmail(emailVal)){ 34 | success = false; 35 | setError(email,'Please enter a valid email') 36 | } 37 | else{ 38 | setSuccess(email) 39 | } 40 | 41 | if(passwordVal === ''){ 42 | success= false; 43 | setError(password,'Password is required') 44 | } 45 | else if(passwordVal.length<8){ 46 | success = false; 47 | setError(password,'Password must be atleast 8 characters long') 48 | } 49 | else{ 50 | setSuccess(password) 51 | } 52 | 53 | if(cpasswordVal === ''){ 54 | success = false; 55 | setError(cpassword,'Confirm password is required') 56 | } 57 | else if(cpasswordVal!==passwordVal){ 58 | success = false; 59 | setError(cpassword,'Password does not match') 60 | } 61 | else{ 62 | setSuccess(cpassword) 63 | } 64 | 65 | return success; 66 | 67 | } 68 | //element - password, msg- pwd is reqd 69 | function setError(element,message){ 70 | const inputGroup = element.parentElement; 71 | const errorElement = inputGroup.querySelector('.error') 72 | 73 | errorElement.innerText = message; 74 | inputGroup.classList.add('error') 75 | inputGroup.classList.remove('success') 76 | } 77 | 78 | function setSuccess(element){ 79 | const inputGroup = element.parentElement; 80 | const errorElement = inputGroup.querySelector('.error') 81 | 82 | errorElement.innerText = ''; 83 | inputGroup.classList.add('success') 84 | inputGroup.classList.remove('error') 85 | } 86 | 87 | const validateEmail = (email) => { 88 | return String(email) 89 | .toLowerCase() 90 | .match( 91 | /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/ 92 | ); 93 | }; -------------------------------------------------------------------------------- /Form Validation/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Register 10 | 11 | 12 |
13 |
14 |

Register

15 |
16 | 17 | 18 |
19 |
20 |
21 | 22 | 23 |
24 |
25 |
26 | 27 | 28 |
29 |
30 |
31 | 32 | 33 |
34 |
35 | 36 |
37 |
38 | 39 | -------------------------------------------------------------------------------- /Form Validation/style.css: -------------------------------------------------------------------------------- 1 | body{ 2 | background: rgb(34,193,195); 3 | background: linear-gradient(0deg, rgba(34,193,195,1) 0%, rgba(121,32,153,1) 86%); 4 | background-attachment: fixed; 5 | margin:0; 6 | font-family: 'Poppins', sans-serif; 7 | } 8 | 9 | #form{ 10 | width:400px; 11 | margin:20vh auto 0 auto; 12 | background-color: whitesmoke; 13 | border-radius: 5px; 14 | padding:30px; 15 | } 16 | 17 | h1{ 18 | text-align: center; 19 | color:#792099; 20 | } 21 | 22 | #form button{ 23 | background-color: #792099; 24 | color:white; 25 | border: 1px solid #792099; 26 | border-radius: 5px; 27 | padding:10px; 28 | margin:20px 0px; 29 | cursor:pointer; 30 | font-size:20px; 31 | width:100%; 32 | } 33 | 34 | .input-group{ 35 | display:flex; 36 | flex-direction: column; 37 | margin-bottom: 15px; 38 | } 39 | 40 | .input-group input{ 41 | border-radius: 5px; 42 | font-size:20px; 43 | margin-top:5px; 44 | padding:10px; 45 | border:1px solid rgb(34,193,195) ; 46 | } 47 | 48 | .input-group input:focus{ 49 | outline:0; 50 | } 51 | 52 | .input-group .error{ 53 | color:rgb(242, 18, 18); 54 | font-size:16px; 55 | margin-top: 5px; 56 | } 57 | 58 | .input-group.success input{ 59 | border-color: #0cc477; 60 | } 61 | 62 | .input-group.error input{ 63 | border-color:rgb(206, 67, 67); 64 | } -------------------------------------------------------------------------------- /Functions/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Loops Demo 8 | 9 | 10 |

11 | 14 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /Functions/script.js: -------------------------------------------------------------------------------- 1 | //Functions - performs specific task 2 | // can be called multiple times 3 | // optionally takes input as 4 | // parameters and optionally 5 | // returns value 6 | 7 | //function declaration 8 | function isPositive(num){//parameter 9 | return num>0 10 | } 11 | 12 | console.log(isPositive(-4))//argument 13 | 14 | function sayHello(){ 15 | console.log('hello') 16 | } 17 | 18 | sayHello() 19 | //hoisting 20 | // JavaScript Hoisting refers to the 21 | // process whereby the interpreter appears 22 | // to move the declaration of functions, 23 | // variables or classes to the top of their 24 | // scope, prior to execution of the code 25 | console.log(findProduct(4,7)) 26 | 27 | function findProduct(a,b){ 28 | return a*b 29 | } 30 | 31 | 32 | console.log(findProduct) 33 | console.log(typeof findProduct) 34 | 35 | //default parameters 36 | // function greet(name='there'){ 37 | // console.log('hi',name) 38 | // } 39 | 40 | // greet('Ram') 41 | // greet() 42 | 43 | //recursion - function calling itself 44 | //factorial - product of first n numbers 45 | //5! = 5*4*3*2*1 = 5*4*3*2*1 46 | function factorial(n){ 47 | if(n==1) 48 | return 1 49 | return n*factorial(n-1) 50 | } 51 | console.log(factorial(5)) 52 | 53 | //function expression 54 | //assigned to a variable as object 55 | let a = 100 56 | 57 | let isEven = function(num){ 58 | return num%2==0 59 | } 60 | console.log(isEven(5)) 61 | console.log(isEven) 62 | 63 | let arr = [ 2, 3, 5, 6, 10] 64 | let findSum = function(arr){ 65 | let sum = 0 66 | for(let val of arr){ 67 | sum += val 68 | } 69 | return sum 70 | } 71 | 72 | console.log(findSum(arr)) 73 | 74 | // let volume = function(l,b,h){ 75 | // return l*b*h 76 | // } 77 | 78 | //arrow function 79 | let volume = (l,b,h) => l*b*h 80 | console.log(volume(7,8,9)) 81 | 82 | let sumOfArr = arr =>{ 83 | let sum = 0 84 | for(let val of arr){ 85 | sum += val 86 | } 87 | return sum 88 | } 89 | console.log(sumOfArr(arr)) 90 | 91 | //area of circle 92 | let area = r => Math.PI*r*r 93 | console.log(area(5)) 94 | 95 | console.clear() 96 | //variable arguments - rest parameters 97 | let prod = function(...args){ 98 | let result = 1 99 | for(let val of args) 100 | result *= val 101 | return result 102 | } 103 | 104 | let prod2 = function(){ 105 | let result = 1 106 | for(i=0;i { 152 | const heading = document.querySelector('h1') 153 | heading.innerHTML = 'hello ' + name 154 | }) 155 | console.clear() 156 | 157 | 158 | //Foreach 159 | arr = ['deepa','suresh','ramya'] 160 | 161 | arr.forEach(print) 162 | 163 | function print(val){ 164 | console.log(val.toUpperCase()) 165 | } 166 | 167 | arr.forEach(val => console.log(val.toUpperCase())) 168 | console.log(arr) 169 | 170 | arr.forEach((val,index,arr)=>{ 171 | arr[index] = val.toUpperCase() 172 | }) 173 | 174 | console.log(arr) 175 | 176 | arr = ['ECE', 'IT', 'CSC', 'EEE'] 177 | 178 | arr.forEach(val => { 179 | const opt = document.createElement('option') 180 | opt.textContent = val 181 | opt.value = val 182 | document.getElementById('branch').appendChild(opt) 183 | }); 184 | 185 | console.clear() 186 | 187 | 188 | //map - executes callback for each array 189 | // element and returns new array 190 | let priceUSD = [20,35,13] 191 | let priceINR = priceUSD.map(x => x *83) 192 | console.log(priceINR) 193 | 194 | priceINR = priceUSD.map(convert) 195 | 196 | function convert(val){ 197 | return val*83 198 | } 199 | 200 | console.log(priceINR) 201 | 202 | const input = [ //array of objects 203 | {name:'John',age:15}, 204 | {name:'Radha',age:45}, 205 | {name:'Kaushik',age:12}, 206 | {name:'Anu',age:21}, 207 | {name:'Divya',age:26} 208 | ] 209 | 210 | const ages = input.map( x => x.age) 211 | console.log(ages) 212 | 213 | 214 | //filter - returns new array by checking 215 | // each value of original arr using 216 | // call back fn 217 | 218 | let cost = [35,234,12,34,54,123] 219 | 220 | let lessThan100 = cost.filter( x => x<100) 221 | console.log(lessThan100) 222 | 223 | //reduce - executes reducer callback 224 | // and returns accumulated result 225 | //arr.reduce(callback[, initialValue]) 226 | //reduce(function (accumulator, currentValue, currentIndex, array)) 227 | 228 | cost = [35,234,12,34,54,123] 229 | let cartTotal = cost.reduce((total,el)=>total+el) 230 | console.log(cartTotal) 231 | 232 | arr2d = [ 233 | ["a", "b", "c"], 234 | ["c", "d", "f"], 235 | ["d", "f", "g"], 236 | ]; 237 | 238 | //result = {a:1,b:1,c:2,d:2...} 239 | let result = {'a':1,'b':2} 240 | result['c'] = 1 241 | console.log(result['d']) 242 | 243 | console.log(arr2d.flat()) 244 | let count = arr2d.flat().reduce( 245 | (accumulator,currVal) => { 246 | if(accumulator[currVal]) 247 | accumulator[currVal]++ 248 | else 249 | accumulator[currVal] = 1 250 | return accumulator 251 | } 252 | ,{}); 253 | 254 | console.log(count) 255 | console.clear() 256 | 257 | let a = 100 258 | 259 | function func1(){ 260 | let b,c 261 | console.log('a is',a) 262 | } 263 | 264 | func1() 265 | a = 200 266 | func1() 267 | 268 | //returning functions - higher order function 269 | //lexical scoping - inner scope can access parent scope variables 270 | 271 | //A closure is the combination of a 272 | //function bundled together (enclosed) 273 | //with references to its surrounding state 274 | //(the lexical environment). 275 | //In other words, a closure gives you 276 | //access to an outer function's scope from 277 | //an inner function. 278 | function outer(name){ 279 | let outerVariable = 'Bread' 280 | function inner(){ 281 | let innerVariable = 'Butter' 282 | console.log('inner variable',innerVariable) 283 | console.log('outer variable',outerVariable) 284 | console.log('a is',a) 285 | console.log('hello',name) 286 | } 287 | return inner 288 | } 289 | 290 | let call1 = outer('Vidya') 291 | call1() 292 | 293 | let call2 = outer('John') 294 | call2() 295 | call1() 296 | 297 | function makeAdder(x){ 298 | return function(y){ 299 | return x+y 300 | } 301 | } 302 | 303 | let add5 = makeAdder(5) 304 | console.log(add5(10)) 305 | 306 | let add100 = makeAdder(100) 307 | console.log(add100(20)) 308 | console.log(add100(45)) 309 | console.log(add5(22)) 310 | 311 | //Memory Management 312 | 313 | let bigNum = 9007199254740991n 314 | 315 | const bigNum2 = BigInt(9007199254740991) 316 | 317 | let a = 100 318 | a = 200 319 | let b = a 320 | b=300 321 | 322 | console.log('a is ',a) 323 | console.log('b is ',b) 324 | 325 | let obj1 = {name:'Danya',age:24} 326 | let obj2 = obj1 327 | 328 | obj1.age = 25 329 | obj2.name = 'ramya' 330 | 331 | console.log('obj1',obj1) 332 | console.log('obj2',obj2) 333 | 334 | let arr1 = [2,3,4] 335 | let arr2 = arr1 336 | arr2[0] = 10 337 | console.log(arr1,arr2) -------------------------------------------------------------------------------- /If Else/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | JS If Else 8 | 9 | 10 |

11 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /If Else/script.js: -------------------------------------------------------------------------------- 1 | //If else - conditional statement 2 | 3 | let pwd_correct = false; 4 | 5 | if (pwd_correct) { 6 | console.log("You are logged in"); 7 | } else { 8 | console.log("Incorrect password"); 9 | } 10 | 11 | // Comparison Operators: == === != !== > < >= <= ?: conditional/ternary 12 | // Logical Operators: && || ! 13 | 14 | age = 65; 15 | gender = "female"; 16 | if (age > 60 && gender === "female") 17 | console.log("You can avail special discount"); 18 | 19 | //max of two numbers 20 | let a = 40, b = 30; 21 | let max 22 | 23 | if(a>b) 24 | max = a 25 | else 26 | max = b 27 | 28 | max = a>b?a:b 29 | 30 | 31 | console.log(max) 32 | 33 | 34 | console.log("Bye"); 35 | -------------------------------------------------------------------------------- /Image Slider/Imgs/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LogicFirstTamil/Javascript-Course/102a823a30dcda34add22b32ceebd26dbe5f3e47/Image Slider/Imgs/1.jpg -------------------------------------------------------------------------------- /Image Slider/Imgs/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LogicFirstTamil/Javascript-Course/102a823a30dcda34add22b32ceebd26dbe5f3e47/Image Slider/Imgs/2.jpg -------------------------------------------------------------------------------- /Image Slider/Imgs/3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LogicFirstTamil/Javascript-Course/102a823a30dcda34add22b32ceebd26dbe5f3e47/Image Slider/Imgs/3.jpg -------------------------------------------------------------------------------- /Image Slider/Imgs/4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LogicFirstTamil/Javascript-Course/102a823a30dcda34add22b32ceebd26dbe5f3e47/Image Slider/Imgs/4.jpg -------------------------------------------------------------------------------- /Image Slider/app.js: -------------------------------------------------------------------------------- 1 | const container = document.querySelector('.container'); 2 | const btns = document.querySelectorAll('.btn') 3 | const imgList = ["1","2","3","4"] 4 | 5 | let index=0 6 | btns.forEach((button)=>{ 7 | button.addEventListener('click',()=>{ 8 | if(button.classList.contains('btn-left')){ 9 | index--; 10 | if(index<0){ 11 | index = imgList.length-1; 12 | } 13 | container.style.background = `url("Imgs/${imgList[index]}.jpg") center/cover fixed no-repeat` 14 | } 15 | else{ 16 | index++; 17 | if(index===imgList.length){ 18 | index = 0; 19 | } 20 | container.style.background = `url("Imgs/${imgList[index]}.jpg") center/cover fixed no-repeat` 21 | } 22 | }) 23 | }) -------------------------------------------------------------------------------- /Image Slider/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Image Slider 11 | 12 | 13 |
14 | 15 | 16 |
17 | 18 | -------------------------------------------------------------------------------- /Image Slider/style.css: -------------------------------------------------------------------------------- 1 | body{ 2 | margin:0; 3 | padding:0; 4 | box-sizing: border-box; 5 | background-color: salmon; 6 | } 7 | 8 | .container{ 9 | min-height: 80vh; 10 | width:60%; 11 | border:8px solid rgb(129, 187, 174); 12 | margin:4rem auto; 13 | border-radius: 5px; 14 | box-shadow: 10px 10px 35px rgba(0,0,0,0.6); 15 | position:relative; 16 | background: url("Imgs/1.jpg") center/cover fixed no-repeat; 17 | transition:background 1s ease-in-out; 18 | } 19 | 20 | .btn-left{ 21 | position:absolute; 22 | top:50%; 23 | left:-2%; 24 | background-color: white; 25 | padding:.4em .6em; 26 | border-radius: 2em; 27 | transform:translateY(calc(-50%)); 28 | cursor: pointer; 29 | } 30 | .btn-right{ 31 | position:absolute; 32 | top:50%; 33 | right:-2%; 34 | background-color: white; 35 | padding:.4em .6em; 36 | border-radius: 2em; 37 | transform:translateY(calc(-50%)); 38 | cursor: pointer; 39 | } -------------------------------------------------------------------------------- /Introduction/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | JS Intro 9 | 10 | 11 |

12 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Introduction/script.js: -------------------------------------------------------------------------------- 1 | //This is an alert 2 | //Single Line Comment 3 | /* 4 | Multi Line Comment 5 | JS Introduction 6 | */ 7 | //dynamically typed language 8 | //variables - 8 bytes 9 | let score = 0; //initialization 10 | 11 | //assignment 12 | // score = 10.5 //1010 13 | // score = 'no score' 14 | 15 | const pi = 3.14; 16 | 17 | //console.log("score is " + score); 18 | 19 | /* 20 | Operators 21 | --------- 22 | 23 | Arithmetic Operators: + - * ** / % ++ -- 24 | Assignment Operators: = += -= *= /= %= **= 25 | Comparison Operators: == === != !== > < >= <= ?: 26 | Logical Operators: && || ! 27 | Bitwise Operators: & | ~ ^ << >> >>> 28 | 29 | */ 30 | 31 | //user input 32 | // let name = prompt("whats your name?") 33 | // console.log('hi ',name) 34 | 35 | // let tickets = prompt('how many tickets do you want?') 36 | // console.log("you should pay ", Number(tickets)*20) 37 | 38 | // let a = prompt("Enter a number") 39 | // console.log(Number(a)+10) 40 | 41 | //String - Group of Characters 42 | 43 | let str1 = "Strive not to be a success, "; 44 | let str2 = "but rather to be a value"; 45 | 46 | /* 47 | Partitioning String 48 | 49 | slice(start, end) 50 | substring(start, end) 51 | substr(start, length) 52 | */ 53 | 54 | // Template Literals 55 | // Introduced in 2015 with ECMAScript6 or ES6 56 | 57 | let firstName = "Ramya"; 58 | let lastName = "Murali"; 59 | let city = "Chennai"; 60 | 61 | console.log(firstName + " " + lastName + " lives in " + city); 62 | 63 | //string interpolation 64 | console.log(`${firstName} ${lastName} lives in ${city}`); 65 | 66 | //multiline string 67 | 68 | let msg = `happy 69 | birthday`; 70 | 71 | console.log(msg) 72 | 73 | //single and double quotes in string 74 | msg = "cat's name is toto"; 75 | 76 | msg = `cat's name is "toto"`; 77 | 78 | console.log(msg) 79 | 80 | //arrays 81 | let num = 10; 82 | let name = "vidhya"; 83 | 84 | let cities = ["Chennai", "Madurai", "Trichy"]; 85 | 86 | let marks = [78, 56, 67, 54, 98]; 87 | 88 | //length - total elements in the array 89 | console.log(marks.length); 90 | 91 | //access 2nd element from start - index starts with 0. 92 | console.log(cities[1]); 93 | 94 | //access 3rd element in array 95 | console.log(cities[3]); 96 | 97 | //last element 98 | console.log(marks[marks.length - 1]); 99 | 100 | //mix of int and string 101 | let arr = [5, 6, 7, "a", "abc", [3, 4]]; 102 | console.log(arr); 103 | console.log(arr[5][1]); 104 | 105 | //2d array 106 | let matrix = [ 107 | [3, 4, 5], 108 | [4, 5, 7], 109 | [6, 7, 8], 110 | ]; 111 | console.log(matrix[2][1]); 112 | 113 | //array methods 114 | let array = ["a", "b", "c", "d", "e"]; 115 | 116 | //push - add element to the end and returns new length 117 | array.push("f"); 118 | console.log(array); 119 | 120 | //pop - removes element from the end and 121 | //returns removed value 122 | console.log(array.pop()); 123 | 124 | //shift - removes element from start of the array 125 | //returns removed value 126 | console.log(array.shift()); 127 | console.log(array); 128 | 129 | //unshift - adds element to the start of the array 130 | //returns new length 131 | console.log(array.unshift("a")); 132 | console.log(array); 133 | 134 | //delete 135 | // delete array[2] 136 | // console.log(array[2]) 137 | 138 | //splice 139 | //1st parameter - starting index 140 | //2nd parameter - no. of elements to be deleted from starting index 141 | //3rd(or more) parameter - values to be inserted from starting index 142 | array.splice(2, 2); //deletes 2 elements starting at index 2 143 | console.log(array); 144 | 145 | array.splice(1, 1, "m"); // replace - deletes element at index 1 and inserts 'm' 146 | console.log(array); 147 | 148 | array.splice(1, 2, "x", "y"); //deletes elements at position 1 and 2 and inserts 'x','y' 149 | console.log(array); 150 | 151 | array.splice(1, 0, "b"); 152 | console.log(array); 153 | 154 | //slice(starting index, ending index) 155 | //ending index not included 156 | console.log(array.slice(1, 2)); 157 | 158 | //reverse 159 | array.reverse(); 160 | console.log(array); 161 | 162 | //join - converts array to string 163 | 164 | let str = array.join(); 165 | console.log(str); 166 | 167 | //split - converts string to array 168 | let str3 = "g,t,r,e"; 169 | let arr3 = str3.split(","); 170 | console.log(arr3); 171 | 172 | //concat and spread operator 173 | let firstArr = [1, 2, 3]; 174 | let secondArr = [4, 5, 6]; 175 | 176 | let joinedArr = [firstArr,secondArr] 177 | console.log(joinedArr) 178 | 179 | joinedArr = firstArr.concat(secondArr) 180 | console.log(joinedArr) 181 | 182 | let joined = [...firstArr,...secondArr] 183 | console.log(joined) 184 | -------------------------------------------------------------------------------- /Introduction/style.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LogicFirstTamil/Javascript-Course/102a823a30dcda34add22b32ceebd26dbe5f3e47/Introduction/style.css -------------------------------------------------------------------------------- /JSON,API/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | JSON,API 8 | 9 | 10 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /JSON,API/script.js: -------------------------------------------------------------------------------- 1 | let json1 = "Dave" 2 | let json2 = 4 3 | let json3 = true 4 | let json4 = [4,5,6,7] 5 | let json5 = { 6 | "Stock":"TCS", 7 | "Price":3500 8 | } 9 | let json6 = `[ 10 | { 11 | "Stock":"TCS", 12 | "Price":3500 13 | }, 14 | { 15 | "Stock":"HUL", 16 | "Price":2500 17 | }, 18 | { 19 | "Stock":"SBI", 20 | "Price":550 21 | } 22 | ]` 23 | 24 | let parsed = JSON.parse(json6) 25 | // console.log(parsed[1].Price) 26 | // console.log(JSON.stringify(parsed)) 27 | 28 | 29 | fetch('https://official-joke-api.appspot.com/jokes/programming/random') 30 | .then((res)=>res.json()) 31 | .then((msg)=>console.log(msg[0].setup,msg[0].punchline)) 32 | .catch((err)=>console.log(err)) 33 | 34 | fetch('https://api-thirukkural.vercel.app/api?num=25') 35 | .then(res => { 36 | if(res.ok) 37 | console.log('success') 38 | else 39 | console.log('Failed') 40 | return res.json() 41 | }) 42 | .then(msg => console.log(msg.line1,msg.line2,msg.tam_exp) ) 43 | .catch(err=>console.log(err)) 44 | 45 | get,post,put,delete 46 | fetch('https://jsonplaceholder.typicode.com/todos/1') 47 | .then(response => response.json()) 48 | .then(json => console.log(json)) 49 | 50 | fetch('https://jsonplaceholder.typicode.com/todos',{ 51 | method:'POST', 52 | headers:{'content-type':'application/json'}, 53 | body:JSON.stringify({ 54 | userId:22, 55 | id:456, 56 | title:'test', 57 | completed:false 58 | }) 59 | }) 60 | .then(response => response.json()) 61 | .then(json => console.log(json)) 62 | 63 | -------------------------------------------------------------------------------- /LengthConverter/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Length Converter 9 | 10 | 11 |
12 |

cm to inches

13 |
14 | 15 |
16 |
17 | 18 |
19 |
20 | 21 |
22 |
23 | 31 | 32 | -------------------------------------------------------------------------------- /LengthConverter/style.css: -------------------------------------------------------------------------------- 1 | html, 2 | body{ 3 | margin: 0; 4 | font-family: 'Poppins', sans-serif; 5 | background-color:#f5e8ba; 6 | } 7 | 8 | #wrapper div,#wrapper h2{ 9 | display:flex; 10 | justify-content: center; 11 | 12 | } 13 | 14 | h2{ 15 | color:#ffeba7; 16 | letter-spacing: 1px; 17 | } 18 | input{ 19 | border-radius: 5px; 20 | border: 2px solid black ; 21 | margin-top:30px; 22 | height:2em; 23 | width:250px; 24 | padding-left:10px; 25 | } 26 | 27 | input:active{ 28 | border:none; 29 | } 30 | #wrapper{ 31 | height:500px; 32 | width:400px; 33 | margin:200px auto; 34 | background-color:#1f2029; 35 | border-radius:10px; 36 | padding:30px; 37 | } 38 | 39 | button{ 40 | margin-top:20px; 41 | background-color:#ffeba7; 42 | border-radius: 4px; 43 | height: 44px; 44 | font-weight: 600; 45 | padding: 0 30px; 46 | letter-spacing: 1px; 47 | border: none; 48 | color: #102770; 49 | } 50 | 51 | button:hover{ 52 | cursor:pointer; 53 | } 54 | #result{ 55 | color:white; 56 | margin-top:20px; 57 | font-size:32px; 58 | } 59 | 60 | -------------------------------------------------------------------------------- /Loops/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Loops Demo 8 | 9 | 10 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Loops/script.js: -------------------------------------------------------------------------------- 1 | //Loops 2 | // console.log('hello') 3 | // console.log('hello') 4 | // console.log('hello') 5 | // console.log('hello') 6 | // console.log('hello') 7 | 8 | //for, while, do-while 9 | 10 | for(let i=1;i<=5;i++){ 11 | console.log('hello') 12 | } 13 | 14 | //print 1 to 5 15 | let i 16 | for(i=1;i<=5;i++){ 17 | console.log(i) 18 | } 19 | 20 | console.log('outside loop ', i) 21 | 22 | //print 10 to 1 23 | for(i=10;i>=1;i--) 24 | console.log(i) 25 | 26 | console.log('while loop') 27 | i=0 28 | while(i>=1){ 29 | console.log(i) 30 | i--; 31 | } 32 | 33 | console.log('outside loop ', i) 34 | 35 | console.log('do while loop') 36 | i=0 37 | do{ 38 | console.log(i) 39 | i--; 40 | }while(i>=1) 41 | 42 | //break - stops the loop 43 | 44 | // while(true){ 45 | // let num = Number(prompt('enter a number')) 46 | // if(!isNaN(num)) 47 | // break; 48 | // } 49 | 50 | console.log('continue demo') 51 | //continue - skips the current iteration 52 | for(i=1;i<=10;i++){ 53 | if(i%3==0) 54 | continue 55 | console.log(i) 56 | } 57 | 58 | //for...of 59 | let arr = ['apple','orange','grapes','mango'] 60 | 61 | for(i=0;i 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Memory Game 11 | 12 | 13 |

Memory Game

14 |
15 | 16 |
17 | 18 | 19 | -------------------------------------------------------------------------------- /Memory Game/mem.js: -------------------------------------------------------------------------------- 1 | const cardsArray = [ 2 | { 3 | name:'dog', 4 | icon:'' 5 | }, 6 | { 7 | name:'hippo', 8 | icon:'' 9 | }, 10 | { 11 | name:'fish', 12 | icon:'' 13 | }, 14 | { 15 | name:'cat', 16 | icon:'' 17 | }, 18 | { 19 | name:'spider', 20 | icon:'' 21 | }, 22 | { 23 | name:'frog', 24 | icon:'' 25 | }, 26 | { 27 | name:'dog', 28 | icon:'' 29 | }, 30 | { 31 | name:'hippo', 32 | icon:'' 33 | }, 34 | { 35 | name:'fish', 36 | icon:'' 37 | }, 38 | { 39 | name:'cat', 40 | icon:'' 41 | }, 42 | { 43 | name:'spider', 44 | icon:'' 45 | }, 46 | { 47 | name:'frog', 48 | icon:'' 49 | } 50 | ]; 51 | 52 | let flippedCards = []; 53 | let matchedPairs = 0; 54 | shuffleCards(); 55 | const gameBoard = document.getElementById('gameBoard') 56 | displayCards(); 57 | 58 | function shuffleCards(){ 59 | for(let i=cardsArray.length-1;i>=0;i--){ 60 | const randIndex = Math.floor(Math.random()*(i+1)); 61 | [cardsArray[i],cardsArray[randIndex]] = [cardsArray[randIndex],cardsArray[i]] 62 | } 63 | } 64 | 65 | function displayCards(){ 66 | cardsArray.forEach((curr,index,arr)=>{ 67 | const card = document.createElement('div'); 68 | card.setAttribute('id',index); 69 | card.classList.add('cardback'); 70 | card.classList.add('active'); 71 | gameBoard.append(card); 72 | card.addEventListener('click',flipCard); 73 | }) 74 | } 75 | 76 | function flipCard(){ 77 | if(flippedCards.length<2 && this.classList.contains('active')){ 78 | let cardId = this.getAttribute('id'); 79 | flippedCards.push(this); 80 | this.classList.remove('cardback'); 81 | this.innerHTML = cardsArray[cardId].icon; 82 | if(flippedCards.length==2){ 83 | setTimeout(checkMatch,1000); 84 | } 85 | } 86 | } 87 | 88 | function checkMatch(){ 89 | const card1Id = flippedCards[0].getAttribute('id'); 90 | const card2Id = flippedCards[1].getAttribute('id'); 91 | if(cardsArray[card1Id].name === cardsArray[card2Id].name){ 92 | flippedCards[0].style.border = 'none'; 93 | flippedCards[0].style.backgroundColor = '#f5e8ba'; 94 | flippedCards[0].innerHTML = ''; 95 | flippedCards[0].classList.remove('active'); 96 | flippedCards[1].classList.remove('active'); 97 | flippedCards[1].style.border = 'none'; 98 | flippedCards[1].style.backgroundColor = '#f5e8ba'; 99 | flippedCards[1].innerHTML = ""; 100 | matchedPairs++; 101 | checkGameOver(); 102 | } 103 | else{ 104 | flippedCards[0].innerHTML = ''; 105 | flippedCards[0].classList.add('cardback'); 106 | flippedCards[1].innerHTML = ''; 107 | flippedCards[1].classList.add('cardback'); 108 | } 109 | flippedCards = []; 110 | } 111 | 112 | function checkGameOver(){ 113 | if(matchedPairs == cardsArray.length/2){ 114 | while(gameBoard.firstChild){ 115 | gameBoard.removeChild(gameBoard.firstChild) 116 | } 117 | gameBoard.innerHTML = 'You Won'; 118 | gameBoard.classList.remove('game'); 119 | gameBoard.classList.add('won'); 120 | } 121 | } 122 | 123 | -------------------------------------------------------------------------------- /Memory Game/style.css: -------------------------------------------------------------------------------- 1 | body{ 2 | margin:0; 3 | padding:0; 4 | font-family:Verdana, Geneva, Tahoma, sans-serif; 5 | background-color: #f5e8ba; 6 | } 7 | 8 | h3{ 9 | font-size:2rem; 10 | text-align: center; 11 | color:crimson 12 | } 13 | 14 | .game{ 15 | display:grid; 16 | margin:40px auto; 17 | grid-template-columns: repeat(4,120px); 18 | grid-row-gap:2em; 19 | align-items: center; 20 | justify-content: center; 21 | } 22 | 23 | #gameBoard div{ 24 | height:150px; 25 | width:80px; 26 | border:2px solid rgb(151, 151, 202); 27 | display:flex; 28 | align-items: center; 29 | justify-content: center; 30 | font-size:2em; 31 | color:brown; 32 | background-color: #e5e5f7; 33 | } 34 | 35 | .cardback{ 36 | background-color: #e5e5f7; 37 | opacity: 0.8; 38 | background-image: linear-gradient(135deg, #444cf7 25%, transparent 25%), linear-gradient(225deg, #444cf7 25%, transparent 25%), linear-gradient(45deg, #444cf7 25%, transparent 25%), linear-gradient(315deg, #444cf7 25%, #e5e5f7 25%); 39 | background-position: 10px 0, 10px 0, 0 0, 0 0; 40 | background-size: 10px 10px; 41 | background-repeat: repeat; 42 | } 43 | 44 | #gameBoard div:hover{ 45 | cursor:pointer; 46 | } 47 | 48 | .won{ 49 | font-size:3em; 50 | display:flex; 51 | justify-content:center; 52 | height:500px; 53 | align-items: center; 54 | color:blue; 55 | width:500px; 56 | margin:0px auto; 57 | } 58 | 59 | -------------------------------------------------------------------------------- /Navbar/bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LogicFirstTamil/Javascript-Course/102a823a30dcda34add22b32ceebd26dbe5f3e47/Navbar/bg.jpg -------------------------------------------------------------------------------- /Navbar/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | NavBar Demo 9 | 10 | 11 | 27 | 28 | 35 | -------------------------------------------------------------------------------- /Navbar/style.css: -------------------------------------------------------------------------------- 1 | body{ 2 | margin:0; 3 | padding:0; 4 | font-family:'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif; 5 | background-image: url('bg.jpg'); 6 | background-size: cover; 7 | background-repeat: no-repeat; 8 | height:100vh; 9 | } 10 | 11 | nav{ 12 | background-color:darksalmon; 13 | font-size: 28px; 14 | width:100%; 15 | display:flex; 16 | align-items:center; 17 | justify-content: space-around; 18 | color:darkslateblue; 19 | } 20 | 21 | nav li{ 22 | display:inline-block; 23 | margin:0 8px; 24 | } 25 | 26 | nav a{ 27 | text-decoration: none; 28 | } 29 | 30 | .logo{ 31 | font-size:36px; 32 | font-weight: bolder; 33 | } 34 | 35 | nav a:hover{ 36 | color:whitesmoke; 37 | } 38 | 39 | .menu-line{ 40 | height:3px; 41 | width:20px; 42 | background-color: darkslateblue; 43 | margin-bottom: 3px; 44 | } 45 | 46 | .menu{ 47 | cursor:pointer; 48 | display:none; 49 | } 50 | 51 | @media all and (max-width:640px){ 52 | nav{ 53 | flex-direction: column; 54 | } 55 | 56 | nav li{ 57 | display:block; 58 | padding:10px 0; 59 | } 60 | ul{ 61 | text-align: center; 62 | padding:0; 63 | display:none; 64 | } 65 | 66 | .logo{ 67 | align-self:flex-start; 68 | margin:10px 0px 0px 30px; 69 | } 70 | 71 | .menu{ 72 | display:block; 73 | position:absolute; 74 | right:20px; 75 | top:25px; 76 | } 77 | 78 | .showmenu{ 79 | display:block; 80 | } 81 | 82 | } -------------------------------------------------------------------------------- /OOP/car.js: -------------------------------------------------------------------------------- 1 | //ES6 - modules 2 | export default class Car{ 3 | drive(){ 4 | console.log("Driving") 5 | } 6 | } 7 | 8 | export function fillGas(){ 9 | console.log('Filling Gas') 10 | } 11 | 12 | export function repair(){ 13 | console.log('Repairing') 14 | } 15 | 16 | // export default Car 17 | // export {fillGas,repair} 18 | 19 | -------------------------------------------------------------------------------- /OOP/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | OOP 8 | 9 | 10 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /OOP/script.js: -------------------------------------------------------------------------------- 1 | import C,{fillGas as fill,repair} from './car.js' 2 | 3 | let car1 = new C() 4 | car1.drive() 5 | fill() 6 | 7 | 8 | let user1 = { 9 | name:'Ramya', 10 | age:22, 11 | login(){ 12 | console.log('You are logged in') 13 | }, 14 | logout(){ 15 | console.log('You are logged out') 16 | } 17 | } 18 | 19 | let user2 = { 20 | name:'Vasanth', 21 | age:24, 22 | login(){ 23 | console.log('Hi',this.name) 24 | console.log('You are logged in') 25 | }, 26 | logout(){ 27 | console.log('You are logged out') 28 | } 29 | } 30 | 31 | let user3 = { 32 | name:'John', 33 | age:21, 34 | login(){ 35 | console.log('Hi',this.name) 36 | console.log('You are logged in') 37 | }, 38 | logout(){ 39 | console.log('You are logged out') 40 | } 41 | } 42 | 43 | user2.login() 44 | user3.login() 45 | 46 | //Class is a template of properties 47 | // and methods 48 | //static - common variables/methods for class 49 | // - accessed with className 50 | //ES6 51 | class User{ // base class, parent class, super class 52 | static numberOfUsers = 0; 53 | constructor(name,age){ 54 | //instance variables 55 | this.name = name; 56 | this.age = age; 57 | User.numberOfUsers++; 58 | } 59 | 60 | login(){ 61 | console.log('Hi',this.name) 62 | console.log('You are logged in') 63 | } 64 | logout(){ 65 | console.log('You are logged out') 66 | } 67 | static displayTotalUsers(){ 68 | console.log('Total number of Users is '+User.numberOfUsers++) 69 | } 70 | } 71 | 72 | let userOne = new User('Vidya',21) 73 | let userTwo = new User('Ramesh',33) 74 | let userThree = new User('Mano',32) 75 | userOne.login() 76 | userTwo.logout() 77 | //console.log('Number of Users',User.numberOfUsers) 78 | User.displayTotalUsers() 79 | 80 | let movie = 'PS1' 81 | let music = new String('ARR') 82 | 83 | //inheritance - acquiring properties of 84 | // - a base class 85 | 86 | //derived class, child class, sub class 87 | class Paiduser extends User{ 88 | constructor(name,age){ 89 | super(name,age); 90 | this.storage = 100; 91 | } 92 | message(){ 93 | console.log('You have 100GB free storage') 94 | } 95 | //overriding 96 | login(){ 97 | console.log('Thank you for your support') 98 | return this 99 | } 100 | } 101 | 102 | let paidUser1 = new Paiduser('Dhana',22) 103 | paidUser1.login() 104 | paidUser1.message() 105 | 106 | //method chaining 107 | 108 | paidUser1.login().message() 109 | 110 | 111 | function User(name,age){ 112 | this.name = name; 113 | this.age = age; 114 | } 115 | 116 | User.prototype.login = function(){ 117 | console.log('hi',this.name) 118 | console.log("You are logged in") 119 | } 120 | 121 | let user1 = new User('Abdul',34) 122 | user1.login() 123 | 124 | //get and set 125 | class Temperature{ 126 | constructor(temp){ 127 | this._temp = temp 128 | } 129 | get temp(){ 130 | return `${this._temp} deg celcius` 131 | } 132 | set temp(temp){ 133 | if(temp>100) 134 | temp = 100 135 | this._temp = temp 136 | } 137 | } 138 | 139 | let temp1 = new Temperature(25) 140 | 141 | temp1.temp = 150 142 | console.log(temp1.temp) 143 | 144 | 145 | 146 | -------------------------------------------------------------------------------- /Objects/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | JS Objects 8 | 9 | 10 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Objects/script.js: -------------------------------------------------------------------------------- 1 | let item = { 2 | name:'phone', 3 | price:25000, 4 | quantity:1, 5 | categories:['electronics','phones'], 6 | dimensions:{ 7 | length:7, 8 | breadth:3.5, 9 | height:.5 10 | } 11 | } 12 | console.log(item) 13 | console.log(item.categories[0]) 14 | console.log(item.dimensions.length) 15 | 16 | //another way to create object 17 | let item2 = new Object(); 18 | item2.name = 'charger' 19 | item2.price = 700 20 | item2.quantity = 1 21 | console.log(item2) 22 | 23 | //accessing object 24 | //dot notation 25 | console.log(item.price) 26 | item.price = 26000 27 | console.log(item.price) 28 | //adding new property 29 | item.returnable = true 30 | console.log(item) 31 | 32 | //square bracket notation 33 | console.log(item['price']) 34 | item['returbale'] = false 35 | 36 | let key = 'price' 37 | item[key] = 27500 38 | item.key = 28000 //doesn't work 39 | console.log(item) 40 | 41 | item = { 42 | name: "phone", 43 | quantity:1, 44 | price:25000, 45 | buy: function(){ 46 | console.log('item added to cart') 47 | }, 48 | addToList(){ 49 | console.log('item added to list') 50 | } 51 | } 52 | item.buy() 53 | item.addToList() 54 | item.buy() 55 | item.addToList() 56 | item.buy() 57 | item.addToList() 58 | item.buy() 59 | item.addToList() 60 | -------------------------------------------------------------------------------- /Promise async await/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Asynchronous JS 8 | 9 | 10 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Promise async await/script.js: -------------------------------------------------------------------------------- 1 | //The Promise object represents the 2 | // eventual completion (or failure) 3 | // of an asynchronous operation ) 4 | 5 | function tatkalBook(){ 6 | return new Promise((resolve,reject) => { 7 | let bookingSuccess = false 8 | if (bookingSuccess) 9 | resolve(850) 10 | else 11 | reject() 12 | }) 13 | } 14 | 15 | // tatkalBook().then((amt)=>console.log(`Thanks buddy! I have trasferred Rs.${amt}`)) 16 | // .catch(()=>console.log("Thanks for trying! I will book a bus")) 17 | 18 | 19 | function tossCoin(){ 20 | return new Promise((resolve,reject)=>{ 21 | //0-head(success) 1 -tail(failure) 22 | const rand = Math.floor(Math.random()*2) 23 | if(rand==0) 24 | resolve() 25 | else 26 | reject() 27 | }) 28 | } 29 | 30 | // tossCoin() 31 | // .then(()=>console.log("Congrats!Its head!You won")) 32 | // .catch(()=>console.log("Sorry!You lost!Its")) 33 | 34 | 35 | let reachA = new Promise((resolve,reject)=>{ 36 | const reached = false 37 | if(reached) 38 | setTimeout(resolve,3000,"Vidya reached") 39 | else 40 | reject("Vidya not reached") 41 | }) 42 | 43 | let reachB = new Promise((resolve,reject)=>{ 44 | const reached = true 45 | if(reached) 46 | setTimeout(resolve,1000,"Ramya reached") 47 | else 48 | reject("Ramya not reached") 49 | }) 50 | 51 | let reachC = new Promise((resolve,reject)=>{ 52 | const reached = true 53 | if(reached) 54 | setTimeout(resolve,2000,"Latha reached") 55 | else 56 | reject("Latha not reached") 57 | }) 58 | 59 | Promise.all([reachA,reachB,reachC]) 60 | .then((message)=>console.log(message)) 61 | .catch((message)=>console.log(message)) 62 | 63 | //promise - pending,resolved,rejected (settled) 64 | Promise.allSettled([reachA,reachB,reachC]) 65 | .then((message)=>console.log(message)) 66 | .catch((message)=>console.log(message)) 67 | 68 | Promise.any([reachA,reachB,reachC]) 69 | .then((message)=>console.log(message)) 70 | .catch((message)=>console.log(message)) 71 | 72 | Promise.race([reachA,reachB,reachC]) 73 | .then((message)=>console.log(message)) 74 | .catch((message)=>console.log(message)) 75 | 76 | //async - always returns a promise 77 | async function fn(){ 78 | return 'hello' 79 | } 80 | 81 | console.log(fn()) 82 | 83 | fn().then((msg)=>console.log(msg)) 84 | 85 | async function asyncstatus(){ 86 | try{ 87 | console.log('hi..') 88 | res = await reachA 89 | console.log(res) 90 | console.log('bye') 91 | } 92 | catch(err){ 93 | console.log(err) 94 | } 95 | } 96 | 97 | asyncstatus() 98 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Javascript-Course 2 | ## files for explanation in the youtube playlist https://www.youtube.com/playlist?list=PLYM2_EX_xVvWA3nMtsoLclwDtVS_rLk6O 3 | -------------------------------------------------------------------------------- /Set and Map/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Set and Map 8 | 9 | 10 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Set and Map/script.js: -------------------------------------------------------------------------------- 1 | //Set Object - Collection of values 2 | // - Values are unique 3 | let arr = [1,1,2,3,4,5,5,5,5,10,8] 4 | let mySet1 = new Set(arr) 5 | console.log(arr) 6 | console.log(mySet1) 7 | 8 | let mySet2 = new Set() 9 | mySet2.add(4) 10 | mySet2.add(5) 11 | mySet2.add('pqr') 12 | mySet2.add({'a':1,'b':2}) 13 | mySet2.add(4) 14 | 15 | console.log(mySet2) 16 | let obj = {'a':1,'b':2} 17 | mySet2.add(obj) 18 | console.log(mySet2) 19 | console.log(mySet2.size) 20 | 21 | console.log(mySet2.has(6)) 22 | console.log(mySet2.delete(4)) 23 | 24 | let arr2 = Array.from(mySet2) 25 | console.log(arr2) 26 | console.clear() 27 | 28 | //Map 29 | //Map objects are collections of 30 | //key-value pairs. 31 | //A key in the Map may only occur once 32 | //key or value can be object 33 | 34 | let map1 = new Map() 35 | map1.set('a',1) 36 | map1.set('b',2) 37 | map1.set('a',3) 38 | console.log(map1) 39 | console.log(map1.size) 40 | console.log(map1.has('c')) 41 | map1.delete('a') 42 | 43 | map1.set('d',2) 44 | map1.set('e',3) 45 | 46 | for(let i of map1){ 47 | console.log(i) 48 | } 49 | 50 | for(let [k,v] of map1){ 51 | console.log(v) 52 | } 53 | 54 | for(let k of map1.keys()){ 55 | console.log(k) 56 | } 57 | 58 | map1.forEach((v,k) => { 59 | console.log('key',k,'value',v) 60 | }) 61 | 62 | //2d array to map 63 | let kvArray = [['a',1],['b',1]] 64 | let map2 = new Map(kvArray) 65 | console.log(map2) 66 | //map to 2d array using spread operator 67 | console.log(...map2) 68 | 69 | 70 | -------------------------------------------------------------------------------- /Snake/app.js: -------------------------------------------------------------------------------- 1 | const gameBoard = document.getElementById('gameBoard'); 2 | const context = gameBoard.getContext('2d'); 3 | const scoreText = document.getElementById('scoreVal'); 4 | 5 | const WIDTH = gameBoard.width; 6 | const HEIGHT = gameBoard.height; 7 | const UNIT = 25; 8 | 9 | let foodX; 10 | let foodY; 11 | let xVel = 25; 12 | let yVel = 0; 13 | let score = 0; 14 | let active=true; 15 | let started = false; 16 | let paused = false; 17 | 18 | let snake = [ 19 | {x:UNIT*3,y:0}, 20 | {x:UNIT*2,y:0}, 21 | {x:UNIT,y:0}, 22 | {x:0,y:0} 23 | ]; 24 | window.addEventListener('keydown',keyPress); 25 | startGame(); 26 | 27 | function startGame(){ 28 | context.fillStyle = '#212121'; 29 | //fillRect(xStart,yStart,width,height) 30 | context.fillRect(0,0,WIDTH,HEIGHT); 31 | createFood(); 32 | displayFood(); 33 | drawSnake(); 34 | } 35 | 36 | function clearBoard(){ 37 | context.fillStyle = '#212121'; 38 | //fillRect(xStart,yStart,width,height) 39 | context.fillRect(0,0,WIDTH,HEIGHT); 40 | } 41 | 42 | function createFood(){ 43 | foodX = Math.floor(Math.random()*WIDTH/UNIT)*UNIT; 44 | foodY = Math.floor(Math.random()*HEIGHT/UNIT)*UNIT; 45 | } 46 | 47 | function displayFood(){ 48 | context.fillStyle = 'red'; 49 | context.fillRect(foodX,foodY,UNIT,UNIT) 50 | } 51 | 52 | function drawSnake(){ 53 | context.fillStyle = 'aqua'; 54 | context.strokeStyle = '#212121'; 55 | snake.forEach((snakePart) => { 56 | context.fillRect(snakePart.x,snakePart.y,UNIT,UNIT) 57 | context.strokeRect(snakePart.x,snakePart.y,UNIT,UNIT) 58 | }) 59 | } 60 | 61 | function moveSnake(){ 62 | const head = {x:snake[0].x+xVel, 63 | y:snake[0].y+yVel} 64 | snake.unshift(head) 65 | if(snake[0].x==foodX && snake[0].y==foodY){ 66 | score += 1; 67 | scoreText.textContent = score; 68 | createFood(); 69 | } 70 | else 71 | snake.pop(); 72 | } 73 | 74 | function nextTick(){ 75 | if(active && !paused){ 76 | setTimeout(() => { 77 | clearBoard(); 78 | displayFood(); 79 | moveSnake(); 80 | drawSnake(); 81 | checkGameOver(); 82 | nextTick(); 83 | }, 200); 84 | } 85 | else if(!active){ 86 | clearBoard(); 87 | context.font = "bold 50px serif"; 88 | context.fillStyle = "white"; 89 | context.textAlign = "center"; 90 | context.fillText("Game Over!!",WIDTH/2,HEIGHT/2) 91 | } 92 | } 93 | 94 | function keyPress(event){ 95 | if(!started){ 96 | started = true; 97 | nextTick(); 98 | } 99 | //pause when space is pressed 100 | if(event.keyCode===32){ 101 | console.log('clicked') 102 | if(paused){ 103 | paused = false; 104 | nextTick(); 105 | } 106 | else{ 107 | paused = true; 108 | } 109 | } 110 | const LEFT = 37 111 | const UP = 38 112 | const RIGHT = 39 113 | const DOWN = 40 114 | 115 | switch(true){ 116 | //left key pressed and not going right 117 | case(event.keyCode==LEFT && xVel!=UNIT): 118 | xVel=-UNIT; 119 | yVel = 0; 120 | break; 121 | //right key pressed and not going left 122 | case(event.keyCode==RIGHT && xVel!=-UNIT): 123 | xVel=UNIT; 124 | yVel=0; 125 | break; 126 | //Up key pressed and not going down 127 | case(event.keyCode==UP && yVel!=UNIT): 128 | xVel=0; 129 | yVel=-UNIT; 130 | break; 131 | //down key pressed and not going up 132 | case(event.keyCode==DOWN && yVel!=-UNIT): 133 | xVel=0; 134 | yVel=UNIT; 135 | break; 136 | 137 | } 138 | } 139 | 140 | function checkGameOver(){ 141 | switch(true){ 142 | case(snake[0].x<0): 143 | case(snake[0].x>=WIDTH): 144 | case(snake[0].y<0): 145 | case(snake[0].y>=HEIGHT): 146 | active=false; 147 | break; 148 | } 149 | } -------------------------------------------------------------------------------- /Snake/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Snake Game 10 | 11 | 12 |

Snake Game

13 |
Press space to pause or continue
14 |
15 | 16 |
Score: 0
17 |
18 | 19 | -------------------------------------------------------------------------------- /Snake/style.css: -------------------------------------------------------------------------------- 1 | *{ 2 | margin:0; 3 | padding:0; 4 | font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif; 5 | background-color: #f5e8ba; 6 | text-align: center; 7 | } 8 | 9 | h2{ 10 | color:darkgreen; 11 | } 12 | 13 | #msg{ 14 | margin-bottom: 1em; 15 | } 16 | 17 | #gameBoard{ 18 | border:3px solid; 19 | } 20 | 21 | #score{ 22 | margin-top: 1em; 23 | font-size:2em; 24 | } 25 | 26 | 27 | -------------------------------------------------------------------------------- /todo/app.js: -------------------------------------------------------------------------------- 1 | let button = document.getElementById('add') 2 | let todoList = document.getElementById('todoList') 3 | let input = document.getElementById('input'); 4 | //local storage,cookies 5 | let todos = []; 6 | window.onload = ()=>{ 7 | todos = JSON.parse(localStorage.getItem('todos')) || [] 8 | todos.forEach(todo=>addtodo(todo)) 9 | } 10 | 11 | button.addEventListener('click',()=>{ 12 | todos.push(input.value) 13 | localStorage.setItem('todos',JSON.stringify(todos)) 14 | addtodo(input.value) 15 | input.value='' 16 | }) 17 | 18 | function addtodo(todo){ 19 | let para = document.createElement('p'); 20 | para.innerText = todo; 21 | todoList.appendChild(para) 22 | 23 | para.addEventListener('click',()=>{ 24 | para.style.textDecoration = 'line-through' 25 | remove(todo) 26 | }) 27 | para.addEventListener('dblclick',()=>{ 28 | todoList.removeChild(para) 29 | remove(todo) 30 | }) 31 | } 32 | 33 | function remove(todo){ 34 | let index = todos.indexOf(todo) 35 | if (index > -1) { 36 | todos.splice(index, 1); 37 | } 38 | localStorage.setItem('todos',JSON.stringify(todos)) 39 | } 40 | -------------------------------------------------------------------------------- /todo/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | ToDo List 9 | 10 | 11 |
12 |

Todo List

13 | 14 | 15 |
16 | 17 |
18 |
19 | 20 | 21 | -------------------------------------------------------------------------------- /todo/style.css: -------------------------------------------------------------------------------- 1 | html, 2 | body{ 3 | margin: 0; 4 | font-family: 'Poppins', sans-serif; 5 | background-color:#f5e8ba; 6 | } 7 | 8 | #wrapper h2{ 9 | display:flex; 10 | justify-content: center; 11 | 12 | } 13 | 14 | h2{ 15 | color:#ffeba7; 16 | letter-spacing: 1px; 17 | } 18 | input{ 19 | border-radius: 5px; 20 | border: 2px solid black ; 21 | margin-top:30px; 22 | height:2.5em; 23 | width:250px; 24 | padding-left:10px; 25 | } 26 | 27 | input:active{ 28 | border:none; 29 | } 30 | #wrapper{ 31 | height:500px; 32 | width:400px; 33 | margin:200px auto; 34 | background-color:#1f2029; 35 | border-radius:10px; 36 | padding:30px; 37 | } 38 | 39 | button{ 40 | margin-top:20px; 41 | background-color:#ffeba7; 42 | border-radius: 4px; 43 | height: 44px; 44 | font-weight: 600; 45 | padding: 0 30px; 46 | letter-spacing: 1px; 47 | border: none; 48 | color: #102770; 49 | } 50 | 51 | button:hover{ 52 | cursor:pointer; 53 | } 54 | #todoList{ 55 | color:white; 56 | font-size:28px; 57 | margin-top:10px; 58 | } 59 | 60 | #todoList p{ 61 | margin:10px 0px; 62 | } 63 | 64 | #todoList p:hover{ 65 | cursor: pointer; 66 | } 67 | 68 | --------------------------------------------------------------------------------