├── LICENSE ├── Notes.md ├── README.md ├── hangman ├── README.md ├── css │ └── style.css ├── game.htm ├── images │ ├── 0.jpg │ ├── 1.jpg │ ├── 10.jpg │ ├── 2.jpg │ ├── 3.jpg │ ├── 4.jpg │ ├── 5.jpg │ ├── 6.jpg │ ├── 7.jpg │ ├── 8.jpg │ ├── 9.jpg │ └── hangman.jpg ├── index.htm └── js │ └── script.js ├── javaScriptPractiseQuestions ├── Loops │ ├── index.html │ ├── script.js │ ├── script1.js │ └── style.css ├── Product │ ├── index.html │ ├── script.js │ └── style.css ├── README.md ├── functions.js ├── maxnumber.js ├── script.js ├── style.css ├── try.js ├── try2.js ├── try3.js └── try4.js └── toDoList ├── README.md ├── favicon.ico ├── index.htm ├── script.js └── style.css /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Akhil Rawat 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Notes.md: -------------------------------------------------------------------------------- 1 | # JavaScript Notes 2 | ## History 3 | 90s main pehla browser aaya tha , uska naam tha NetScape Navigator aur wo browser sirf html Language hi support karta tha aur usme sirf Text , Pictures, Link(Basahilaic HTML) hote the aur kuch nahi hota tha. 4 | Baadme CSS Language aayi aur jis ke madad se hum page ko sundar dikhapaye par abhi bhi humari websites interactive nnah thi. 5 | ## JavaScript 6 | Jab 1995 me JavaScript aayi tab humari websites me interactivity aayi. For example aagar user sensitive information access kar raha hai ya yir use change kar raha hai to hum user to ek alert popup dikhate hai. Ye wk bahut basic example hai ki javascript humari websites me interactivity kese lata hai. 7 | Saal 91/92 main Java/C/C++ bahut popular languages thi Python nayi language thi zyada log us par bharosa nahi karte the. 8 | ## Static and Dynamic 9 | Humari kuch programming languages static hoti hai aur kuch languages dynamic.Static ka matlab ki hame variables ko define unke type ke saath define karna padta hain jaise ki java main. Ex int a = 2 , string b = “navgurukl”, float c = 3.5, 10 | In sab example main hame variables ke pehele unka type diya hain ye sab `Static` language main use hota hain, Java static language hain, kyuki usme hame variables ke pehele uska data type declare karna padta hain. 11 | Dynamic ka matlab ki hame variables ke pahile uske type nahi declare nahi karna padta hain. Ex a = 2, b = “Bhavnesh”and c = 3.5. Ye sab dynamic language ke examples hain.Python and JavaScript ye dynamic language hain kyuki usme variables ke types pecify nahi karne padte hain. 12 | ## Using JavaScript 13 | Python/Java/C/C++ ye languages browser ke liye nahi bani hai on the other hand JavaScript humari browsers ke liye bani hui hai. 14 | Har browser ka alage JavaScript engine hota hai JavaScript chalane ke liye. Jese Google Chrome V8 use karta hia aur Firefox SpiderMonkey use karta hai. 15 | JS engine ek program hai jo JavaScipt ko run karta hai. 16 | ## Rendering 17 | Rendering ka mtalab hota hai 'fetching data'. Iska example ho sakta hi ek Class se uske methods lana. 18 | ## Python Model 19 | Agar me python me 'google.com' ki request karu aur fir uske baad kuch print karau to jab tak request 'google.com' se data fetch nahi kar leta tab tak 'Hello World' Print Nahi hoga. 20 | ```Python 21 | import requests 22 | response = requests.get("https://google.com") 23 | print('Hello World') 24 | ``` 25 | ## JavaScript Model 26 | Arar me javaScript me same task perform karu to mera Hello World pehele print hoga aur Data baad me aayega. Java Script dono task ko saath me run karega to ```log('Hello World)``` me 'google.com' ko fetch karne se kam time lagta hai is liye vo pehele ho jata hai baad me ```log('Hello World)``` hota hai. 27 | Ek example se samajte hai. Supposse 'A' or 'B' ki kitchen me turn hai to 'A' ne 'B' ko bola ke dukan se pyaaz le aao to 'B' to chala gaya pyaaz lena ab 'A' free hai to vo tamatar kaat sakta hai pr nahi kaata vo pyaaz ke aane ka wait karta hai. 28 | To ye upar wala example hai python ka. 29 | Agra 'A' 'B' ko bhej kar tamtar kaatne lagjay to vo javascript ke tarah behave kar raha hai. 30 | ```JavaScript 31 | const axios = require('axios') 32 | axios.get('https://google/com') 33 | .then(response => { 34 | console.log('Data aagaya') 35 | } 36 | }) 37 | .catch(error => { 38 | console.log('Error aagaya'); 39 | }); 40 | 41 | console.log('Hello World') 42 | ``` 43 | ## Event Driven Programming 44 | Agra aap ko apna facebook account dekhna hai to aap apa id and password dal kar ```log in``` par click karte ho, vo click karna ek event ho jata hai. Log in tabhi hoga jab aap click karenge. To event ke maddad se humare program chalte hai. Vo events mostly user inputs hote hai. 45 | ## Callback functions 46 | Agar hum meeting me hote hai to jab bhi hume koi call karta hai to ho hum bolte hai ki mai kuch kaam kar raha hu mai aap ko call back karunga. Similarly, JS me hum jab hum koi aur kaa kar rahe hote hai to hum ek callback function likhdete hai jise jab vo task ho jaya to hum aupe kaam kar sake. For exaple jab google.com ka data aajay to mai use scrape karu to mai ek callback function likhunga. 47 | ## Event Loop 48 | Event Loop ek infinite loop hai basically jo chalta reheta hia humare browser me aur ye check karta hai ki koi event to nahi hua. Agar Event aata hai to vo callback kar deta hai. Agar aap google.com ko open karenge ke aur 1 ghante tak chode denge fir ek ghante baad aap useme kuch search karenge to apki search tabhi bhi hogi. Ye possible event loop ki madad se he hota hai. 49 | ## Sync and Async 50 | Jab hum koi task synchronously execute karte hai to hum wait karte hai ki pehla step kahata ho tab hum dusra shuruu kare. Eg. Python 51 | Jab hum koi task asynchronously execute karte hai to we can move on to step 2 agar step 1 complete nahi bhi hua hai to. Is me hum wait nahi karte. Eg. JavaScript 52 | ## Blocking and Non-blocking 53 | Blocking Tasks vo hote hai jisme hum cpu ka use kar rahe hai. for example 2 + 3 ek blocking task hai. 54 | Requests ka use karke data fetch karna non-blocking hai kyuki is me humari I/O devices use ho rahi hai, CPU nahi use ho raha hai. 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # JavaScript 2 | All Project implemented by me in JavaScript. 3 | -------------------------------------------------------------------------------- /hangman/README.md: -------------------------------------------------------------------------------- 1 | # Hangman 2 | Making Hangman game in JavaScript with the help of HTML and CSS 3 | -------------------------------------------------------------------------------- /hangman/css/style.css: -------------------------------------------------------------------------------- 1 | body{ 2 | background-color: pink; 3 | } 4 | h1 { color: #111; font-family: 'Helvetica Neue', sans-serif; font-size: 50px; font-weight: bold; letter-spacing: -1px; line-height: 1; text-align: center; } 5 | h2 { 6 | font: 400 40px/1.5 Helvetica, Verdana, sans-serif; 7 | margin: 0; 8 | padding: 0; 9 | } 10 | 11 | ul { 12 | list-style-type: none; 13 | margin: 0; 14 | padding: 0; 15 | } 16 | 17 | li { 18 | font: 200 20px/1.5 Helvetica, Verdana, sans-serif; 19 | border-bottom: 1px solid #ccc; 20 | } 21 | 22 | li:last-child { 23 | border: none; 24 | } 25 | 26 | li a { 27 | text-decoration: none; 28 | color: #000; 29 | display: block; 30 | width: 200px; 31 | 32 | -webkit-transition: font-size 0.3s ease, background-color 0.3s ease; 33 | -moz-transition: font-size 0.3s ease, background-color 0.3s ease; 34 | -o-transition: font-size 0.3s ease, background-color 0.3s ease; 35 | -ms-transition: font-size 0.3s ease, background-color 0.3s ease; 36 | transition: font-size 0.3s ease, background-color 0.3s ease; 37 | } 38 | 39 | li a:hover { 40 | font-size: 30px; 41 | background: #f6f6f6; 42 | } 43 | .list{ 44 | float: left; 45 | } 46 | .image{ 47 | float: right; 48 | } 49 | 50 | -------------------------------------------------------------------------------- /hangman/game.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Hangman 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /hangman/images/0.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pradeep8909/JavaScript/41d2a6003599ad80cde20a3126f1b7536e9e40e1/hangman/images/0.jpg -------------------------------------------------------------------------------- /hangman/images/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pradeep8909/JavaScript/41d2a6003599ad80cde20a3126f1b7536e9e40e1/hangman/images/1.jpg -------------------------------------------------------------------------------- /hangman/images/10.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pradeep8909/JavaScript/41d2a6003599ad80cde20a3126f1b7536e9e40e1/hangman/images/10.jpg -------------------------------------------------------------------------------- /hangman/images/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pradeep8909/JavaScript/41d2a6003599ad80cde20a3126f1b7536e9e40e1/hangman/images/2.jpg -------------------------------------------------------------------------------- /hangman/images/3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pradeep8909/JavaScript/41d2a6003599ad80cde20a3126f1b7536e9e40e1/hangman/images/3.jpg -------------------------------------------------------------------------------- /hangman/images/4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pradeep8909/JavaScript/41d2a6003599ad80cde20a3126f1b7536e9e40e1/hangman/images/4.jpg -------------------------------------------------------------------------------- /hangman/images/5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pradeep8909/JavaScript/41d2a6003599ad80cde20a3126f1b7536e9e40e1/hangman/images/5.jpg -------------------------------------------------------------------------------- /hangman/images/6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pradeep8909/JavaScript/41d2a6003599ad80cde20a3126f1b7536e9e40e1/hangman/images/6.jpg -------------------------------------------------------------------------------- /hangman/images/7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pradeep8909/JavaScript/41d2a6003599ad80cde20a3126f1b7536e9e40e1/hangman/images/7.jpg -------------------------------------------------------------------------------- /hangman/images/8.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pradeep8909/JavaScript/41d2a6003599ad80cde20a3126f1b7536e9e40e1/hangman/images/8.jpg -------------------------------------------------------------------------------- /hangman/images/9.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pradeep8909/JavaScript/41d2a6003599ad80cde20a3126f1b7536e9e40e1/hangman/images/9.jpg -------------------------------------------------------------------------------- /hangman/images/hangman.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pradeep8909/JavaScript/41d2a6003599ad80cde20a3126f1b7536e9e40e1/hangman/images/hangman.jpg -------------------------------------------------------------------------------- /hangman/index.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hangman 6 | 7 | 8 | 9 |

Welcome to Hangman

10 |
11 | 23 |
24 |
25 | Hangman.jpg 26 |
27 | 28 |
29 |

Start

30 |
31 | 32 | 33 | -------------------------------------------------------------------------------- /hangman/js/script.js: -------------------------------------------------------------------------------- 1 | function diffSubmit() { 2 | var difficulty = document.getElementById("diff").value; 3 | return difficulty; 4 | } 5 | function getSecretWord() { 6 | var secWord = "coot"; 7 | return secWord; 8 | } 9 | function guessLetter() { 10 | var guess = document.getElementById("guess").value; 11 | return guess; 12 | } 13 | function choose(choices) { 14 | var index = Math.floor(Math.random() * choices.length); 15 | return choices[index]; 16 | } 17 | function isWordGuessed(secretWord, guessedWord) { 18 | if (String(secretWord) === String(guessedWord)) { 19 | return true; 20 | } 21 | return false; 22 | } 23 | function getGuessedWord(secretWord, lettersGuessed) { 24 | var index = 0; 25 | var guessedWord = ""; 26 | while (index < secretWord.length) { 27 | if (secretWord[index] in lettersGuessed) { 28 | guessedWord += secretWord[index]; 29 | } else { 30 | guessedWord += "_"; 31 | } 32 | } 33 | return guessedWord; 34 | } 35 | function getAvailableLetters(lettersGuessed) { 36 | var letters = ""; 37 | for (var i = 97; i < 123; i++) { 38 | letters += String.fromCharCode(i); 39 | } 40 | var lettersLeft = ""; 41 | for (var letter in letters) { 42 | if (lettersGuessed.indexOf(letter) === -1) { 43 | lettersLeft += letter; 44 | } 45 | } 46 | return lettersLeft; 47 | } 48 | function getHint(secretWord, letterGuessed) { 49 | var hintarray = []; 50 | for (letter in secret_word) { 51 | if (letterGuessed.indexOf(letter) === -1) { 52 | hintList.push(letter); 53 | } 54 | } 55 | return choose(hintList); 56 | } 57 | function hangman(secretWord) { 58 | console.log("Hangman"); 59 | document.write("

Welcome to the game, Hangman

"); 60 | document.write("

Enter Difficulty : Easy, Medium or Hard

"); 61 | document.write( 62 | '
' 63 | ); 64 | var difficulty = diffSubmit(); 65 | if (difficulty.toLowerCase() === "easy") { 66 | var lives = 10; 67 | var livesArray = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; 68 | } else if (difficulty.toLowerCase() === "medium") { 69 | var lives = 6; 70 | var livesArray = [0, 2, 4, 5, 7, 8, 10]; 71 | } else { 72 | var lives = 3; 73 | var livesArray = [0, 4, 7, 10]; 74 | } 75 | var lettersGuessed = []; 76 | 77 | while (true) { 78 | if (lives === 0) { 79 | document.write("

Remaining Lives : 0

"); 80 | document.write("

You Lost!

"); 81 | document.write("

The word was " + secretWord + ".

"); 82 | break; 83 | } 84 | document.write( 85 | '
' 86 | ); 87 | var guessedLetter = guessLetter(); 88 | if (secretWord.indexOf(guessedLetter) != -1) { 89 | lettersGuessed.push(guessedLetter); 90 | guessedWord = getGuessedWord(secretWord, lettersGuessed); 91 | if (isWordGuessed(secretWord, guessedWord) === true) { 92 | document.write("

You Won!

"); 93 | return; 94 | } 95 | } else { 96 | var picture = livesArray[image]; 97 | image += 1; 98 | lives -= 1; 99 | document.write('"); 100 | document.write("

Please try again!

"); 101 | break; 102 | } 103 | } 104 | } 105 | secretWord = getSecretWord(); 106 | hangman(secretWord); 107 | -------------------------------------------------------------------------------- /javaScriptPractiseQuestions/Loops/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | Document 9 | 10 | 11 | 12 |

Odd or Even

13 |
14 |

EVEN

15 |

ODD

16 | 17 | 18 | -------------------------------------------------------------------------------- /javaScriptPractiseQuestions/Loops/script.js: -------------------------------------------------------------------------------- 1 | for(var i = 0; i < 101; i++){ 2 | if(i%2 === 0){ 3 | div = '
' 6 | } 7 | } 8 | document.write(div) 9 | -------------------------------------------------------------------------------- /javaScriptPractiseQuestions/Loops/script1.js: -------------------------------------------------------------------------------- 1 | var number = parseInt(prompt('Enter a number to get the Multiplication Table')); 2 | if (!isNaN(number)){ 3 | ul = "' 9 | document.write(ul) 10 | }else{ 11 | alert('Please Enter a Valid Number'); 12 | } 13 | -------------------------------------------------------------------------------- /javaScriptPractiseQuestions/Loops/style.css: -------------------------------------------------------------------------------- 1 | h1{ 2 | margin: 20px; 3 | padding: 20px; 4 | text-align: center; 5 | background-color: #ecfffc; 6 | } 7 | body{ 8 | text-align: center; 9 | } 10 | div{ 11 | margin: 20px; 12 | padding: 20px; 13 | display: inline-block; 14 | width: 35%; 15 | } 16 | ul{ 17 | list-style-type: none; 18 | padding: 0px; 19 | } 20 | h2{ 21 | padding: 10px 0px; 22 | } 23 | li{ 24 | padding: 10px 0px; 25 | } 26 | .odd{ 27 | background-color: tomato; 28 | color: #fff; 29 | } 30 | .even{ 31 | background-color: blue; 32 | color: #fff; 33 | } 34 | -------------------------------------------------------------------------------- /javaScriptPractiseQuestions/Product/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Document 6 | 7 | 8 | 9 |

Check if the product is available

10 | 11 | 12 | -------------------------------------------------------------------------------- /javaScriptPractiseQuestions/Product/script.js: -------------------------------------------------------------------------------- 1 | var products = "apple blackberry banana tomato broccoli pumpkin"; 2 | userInupt = prompt('Type "1" to check if a product is available:\nType "2" to list all the products:\nType anything to quit:'); 3 | if (userInupt === '2'){ 4 | document.write("

Product available in the store: " + products + "

"); 5 | }else if(userInupt === '1'){ 6 | var product = prompt('Enter the name of the product to see if it is available'); 7 | if (products.indexOf(product) === -1){ 8 | document.write ("

Sorry the Product is not available.

"); 9 | }else{ 10 | document.write ("

The Product is available

"); 11 | } 12 | }else{ 13 | document.write("

Refresh the page if you want to look for a product or a list of product

") 14 | } -------------------------------------------------------------------------------- /javaScriptPractiseQuestions/Product/style.css: -------------------------------------------------------------------------------- 1 | h1{ 2 | padding: 20px; 3 | margin: 20px; 4 | text-align: center; 5 | background-color: blueviolet; 6 | color: #fff; 7 | font-size: 2.5em; 8 | } 9 | p{ 10 | padding: 20px; 11 | margin: 20px; 12 | font-size: 1.5em; 13 | 14 | } 15 | .info{ 16 | background-color: orange; 17 | color: #fff; 18 | } 19 | .error{ 20 | background-color: red; 21 | color: #fff; 22 | } 23 | .success{ 24 | background-color: green; 25 | color: white; 26 | } -------------------------------------------------------------------------------- /javaScriptPractiseQuestions/README.md: -------------------------------------------------------------------------------- 1 | # Practise JavaScrip 2 | I practised some logical problems in JavaScript. 3 | -------------------------------------------------------------------------------- /javaScriptPractiseQuestions/functions.js: -------------------------------------------------------------------------------- 1 | function HelloWorld(){ 2 | console.log('Hello World!') 3 | console.log('From the function HelloWorld!') 4 | } 5 | HelloWorld() -------------------------------------------------------------------------------- /javaScriptPractiseQuestions/maxnumber.js: -------------------------------------------------------------------------------- 1 | var array = [10,-234,3242,32,43,232] 2 | //Program to find the max number within an array 3 | var max = array[0] 4 | array.forEach(function(element){ 5 | if (element > max){ 6 | max = element; 7 | } 8 | } 9 | ) 10 | console.log(max) -------------------------------------------------------------------------------- /javaScriptPractiseQuestions/script.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pradeep8909/JavaScript/41d2a6003599ad80cde20a3126f1b7536e9e40e1/javaScriptPractiseQuestions/script.js -------------------------------------------------------------------------------- /javaScriptPractiseQuestions/style.css: -------------------------------------------------------------------------------- 1 | h1{ 2 | padding: 20px; 3 | text-align: center; 4 | margin: 20px; 5 | font-size: 2.5em; 6 | color: chartreuse; 7 | font-style: italic; 8 | background-color: blueviolet 9 | } -------------------------------------------------------------------------------- /javaScriptPractiseQuestions/try.js: -------------------------------------------------------------------------------- 1 | // alert('JavaScript from script.js') 2 | // var myName = "Akhil Rawat" 3 | // var myAge = 23; 4 | // console.log('My Name : '+ myName); 5 | // console.log('My Age : '+ myAge); 6 | // alert('My Name : '+ myName + "\nMy Age :" + myAge) 7 | // numeric 8 | // var num = 10.22; 9 | // console.log(num); 10 | // // string 11 | // var myName = 'Akhil' 12 | // console.log(myName); 13 | // //type 14 | // console.log(typeof myName); 15 | // // boolean 16 | // var isHere = false; 17 | // console.log(isHere); 18 | // //type 19 | // console.log(typeof isHere); 20 | // // string 21 | // var a = "a"; 22 | // console.log(a); 23 | // //type 24 | // console.log(typeof a); 25 | // // null 26 | // a = null 27 | // console.log(a); 28 | // //type 29 | // console.log(typeof a); 30 | // // undefined 31 | // var x; 32 | // console.log(x); 33 | // //type 34 | // console.log(typeof x); 35 | // // string 36 | // var willChange = "change"; 37 | // console.log(willChange); 38 | // //type 39 | // console.log(typeof willChange); 40 | // // boolean 41 | // var willChange = true; 42 | // console.log(willChange); 43 | // //type 44 | // console.log(typeof willChange); 45 | // // numeric 46 | // var willChange = -22; 47 | // console.log(willChange); 48 | // //type 49 | // console.log(typeof willChange); 50 | // //type 51 | // console.log(typeof -11); 52 | /* 53 | #This is a multi-line comment 54 | #JavaScript Rules 55 | #Leave Comments 56 | #JavaScript is case-sensitive 57 | #Use camel-case 58 | #Make use of whitespacing to make you code redable 59 | #Variable names begin with letter / $ / _ 60 | #Variable names can contain letter a-z / A-Z 61 | #Variable names cannot be reserved keywords 62 | */ 63 | // var x = 7; 64 | // var y = 10; 65 | // var result = 4%3; 66 | // console.log(result) 67 | // var name = prompt('What is your name?'); 68 | // console.log("Welcome " + name); 69 | // alert("Welcome " + name) 70 | // alert("The length of your name is " + name.length) 71 | // var name = 'Your name\'s "Akhil Rawat"'; 72 | // alert(name); 73 | // var age = prompt("What is your age?"); 74 | // console.log('After 5 years, you will be: ' + (parseInt(age) + 5) + ' years old.'); 75 | // var a =3; 76 | // console.log(a); 77 | // console.log(typeof a); 78 | // 79 | // a = a.toString(); 80 | // console.log(a); 81 | // console.log(typeof a); 82 | // var a = 'On'; 83 | // var b = 9; 84 | // c = a+b; 85 | // console.log(c); 86 | // var str = 200.65; 87 | // var result = Math.ceil(0.9); 88 | // console.log(result); 89 | // var result = Math.floor(0.9); 90 | // console.log(result); 91 | // var result = Math.min(10,20,-5,-23213); 92 | // console.log(result); 93 | // var result = Math.max(10,20,-5,-23213); 94 | // console.log(result); 95 | //var name = prompt("What is your name?"); 96 | //var age = prompt("What is your age?"); 97 | //var email = prompt("What is your email?"); 98 | //var password = prompt("What is your password?"); 99 | //alert("Name : " + name + "\nAge : " + age + "\nEmail : " + email + "\nPassword : " + password); -------------------------------------------------------------------------------- /javaScriptPractiseQuestions/try2.js: -------------------------------------------------------------------------------- 1 | //var age = parseInt(prompt("How old are you?")); 2 | //console.log("Only +18 can access the website"); 3 | //if (isNaN(age)){ 4 | // alert('The age must be an Integer!') 5 | //} 6 | //else{if ( age >= 18){ 7 | // alert('Welcome to the Website!'); 8 | // 9 | //} else if (age > 13) { 10 | // alert('You are not allowed to access the website!'); 11 | // console.log('You are still a Teenager!'); 12 | //} else{ 13 | // alert('You are not allowed to access the website!'); 14 | // console.log('You are too young!'); 15 | //} 16 | // 17 | //} 18 | //if ("1") { 19 | // console.log('True') 20 | //} else{ 21 | // console.log('False') 22 | //} 23 | //var x = 11; 24 | //if (x === 5){ 25 | // console.log("X IS 5"); 26 | //}else if (x === 6){ 27 | // console.log("X IS 6"); 28 | //}else if (x === 7){ 29 | // console.log("X IS 7"); 30 | //}else if (x === 8){ 31 | // console.log("X IS 8"); 32 | //}else if (x === 9){ 33 | // console.log("X IS 9"); 34 | //}else if (x === 10){ 35 | // console.log("X IS 10"); 36 | //}else{ 37 | // console.log("X is not 5,6,7,8,9 or 10"); 38 | //} 39 | //var x = 4 40 | //switch (x){ 41 | // case 5: 42 | // console.log('X is 5'); 43 | // break; 44 | // case 6: 45 | // case 7: 46 | // console.log('X is 6 or 7'); 47 | // break; 48 | // case 8: 49 | // console.log('X is 8'); 50 | // break; 51 | // case 9: 52 | // console.log('X is 9'); 53 | // break; 54 | // case 10: 55 | // console.log('X is 10'); 56 | // break; 57 | // default: 58 | // console.log("X is not 5,6,7,8,9 or 10") 59 | // 60 | // 61 | //} 62 | var random = Math.ceil(Math.random()*5) 63 | var user = parseInt(prompt("Enter a random number\Between 1-5 ")) 64 | if(user === random){ 65 | alert('You Won!') 66 | }else{ 67 | alert('You Lose!') 68 | } 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /javaScriptPractiseQuestions/try3.js: -------------------------------------------------------------------------------- 1 | user = prompt('If you want to find the greatest number among three numbers enter y/yes/Y/Yes if not then you can press any other key.') 2 | if ((user === 'y')||(user === 'Y')||(user === 'Yes')||(user === 'yes')){ 3 | number1 = parseFloat(prompt('Enter the first number')); 4 | number2 = parseFloat(prompt('Enter the second number')); 5 | number3 = parseFloat(prompt('Enter the first number')); 6 | if (number1 > number2){ 7 | if (number1 > number3){ 8 | alert(String(number1) + " is the greatest.") 9 | }else if (number3 > number1){ 10 | alert(String(number3) + " is the greatest.") 11 | } 12 | }else if (number2 > number3){ 13 | alert(String(number2) + " is the greatest.") 14 | }else{ 15 | alert(String(number3) + " is the greatest.") 16 | } 17 | }else{ 18 | alert('Thanks for Playing!\nPress F5 to play again.') 19 | } -------------------------------------------------------------------------------- /javaScriptPractiseQuestions/try4.js: -------------------------------------------------------------------------------- 1 | var date = new Date(); 2 | console.log(date) 3 | var today = date.getDay(); 4 | console.log(today) 5 | var res; 6 | switch(today){ 7 | case 0: 8 | res = 'sunday'; 9 | break; 10 | case 1: 11 | res = 'monday'; 12 | break; 13 | case 2: 14 | res = 'tuesday'; 15 | break; 16 | case 3: 17 | res = 'wednesday'; 18 | break; 19 | case 4: 20 | res = 'thursday'; 21 | break; 22 | case 5: 23 | res = 'friday'; 24 | break; 25 | case 6: 26 | res = 'saturday'; 27 | break; 28 | } 29 | console.log(res) 30 | var guess = prompt('What day is today?') 31 | if (guess === res){ 32 | alert('You Won!') 33 | }else{ 34 | alert('You lost!') 35 | } -------------------------------------------------------------------------------- /toDoList/README.md: -------------------------------------------------------------------------------- 1 | # To-Do-List 2 | Basic To-Do List implemented with the help of JavaScript 3 | -------------------------------------------------------------------------------- /toDoList/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pradeep8909/JavaScript/41d2a6003599ad80cde20a3126f1b7536e9e40e1/toDoList/favicon.ico -------------------------------------------------------------------------------- /toDoList/index.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | To-Do List 7 | 8 |

To Do List

9 |
10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /toDoList/script.js: -------------------------------------------------------------------------------- 1 | // Exercise: Create a to do list application 2 | 3 | // todoList function used on button click to get user input and 4 | function todoList() { 5 | // store user value 6 | var item = document.getElementById('todoInput').value 7 | // create a text node from the user input 8 | var text = document.createTextNode(item) 9 | // create a li tag 10 | var newItem = document.createElement('li') 11 | // add the user input to the li tag 12 | newItem.appendChild(text) 13 | // append the li to the html todoList id tag 14 | document.getElementById('todoList').appendChild(newItem) 15 | } -------------------------------------------------------------------------------- /toDoList/style.css: -------------------------------------------------------------------------------- 1 | h1 { 2 | color: white; 3 | font-family: 'Helvetica Neue', sans-serif; 4 | font-size: 100px; 5 | font-weight: bold; 6 | text-align: center; 7 | background-color: #4CAF50; 8 | margin-top: 0% 9 | } 10 | body{ background-color: whitesmoke;} 11 | ul{ 12 | align-self: auto; 13 | margin-right: 35%; 14 | margin-left: 43%; 15 | } 16 | #todoInput{ 17 | padding:8px; 18 | border-color: darkturquoise; 19 | width:20% 20 | } 21 | 22 | .button { 23 | background-color: #4CAF50; /* Green */ 24 | border: none; 25 | color: white; 26 | padding: 15px 32px; 27 | text-align: center; 28 | text-decoration: none; 29 | display: inline-block; 30 | font-size: 16px; 31 | } 32 | #todoForm{ 33 | text-align: center; 34 | } --------------------------------------------------------------------------------