This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Observer the body tag of all html files. use validateLogIn function to verfy the login activity | |
| function validateLogIn () { | |
| const uName = document.getElementById('uName') | |
| const signOut = document.getElementById('signout') | |
| signOut.addEventListener('click', () => { | |
| sessionStorage.clear('login') | |
| window.location.href = '../sign-in.html' | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const message = document.getElementById('message') | |
| const form = document.getElementById('sign-in') | |
| const username = document.getElementById('userName') | |
| const password = document.getElementById('password') | |
| form.addEventListener('submit', (event) => { | |
| event.preventDefault() | |
| const localUser = localStorage.getItem('user') | |
| console.log('localUser', localUser) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| console.log('user registration') | |
| const form = document.getElementById('registerForm') | |
| console.log('form', form) | |
| form.addEventListener('submit', (event) => { | |
| event.preventDefault() | |
| const fullname = document.getElementById('fullname') | |
| const username = document.getElementById('username') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <h1 id="country">What country do you live in?</h1> | |
| <script> | |
| const heading = document.getElementById('country') | |
| // const localCountry = localStorage.getItem('country') | |
| // console.log('localCountry', localCountry) | |
| const sessionCountry = sessionStorage.getItem('country') | |
| if (sessionCountry) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const movieList = document.getElementById('movie-list') | |
| const search = document.getElementById('search') | |
| const main = document.getElementById('main') | |
| search.addEventListener('input', () => { | |
| const value = search.value.toLowerCase() | |
| const filtered = movies.filter(movie => { | |
| // title, genre, director, cast | |
| const title = movie.title.toLowerCase() | |
| const titleIncludes = title.includes(value) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script> | |
| const grades = ['a', 'a', 'b', 'f', 'a', 'd', 'a', 'b', 'f'] | |
| for (let i = 0; i < grades.length; i++) { | |
| const grade = grades[i] | |
| console.log('traditional', grade) | |
| } | |
| for (const grade of grades) { | |
| console.log('of', grade) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const grades = ['a', 'a', 'b', 'a', 'd', 'a', 'b'] | |
| const uniqueGrades = new Set(grades) | |
| console.log('uniqueGrades', uniqueGrades) | |
| const uniqueGradesArray = [...uniqueGrades] | |
| console.log('uniqueGradesArray', uniqueGradesArray) | |
| const set = new Set() | |
| set.add(1) | |
| set.add('hello') | |
| set.add(true) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script> | |
| function vehicleFactory (speed) { | |
| // 1. Declare a new object | |
| const vehicle = {} | |
| // 2. Customize the object | |
| vehicle.distance = 0 | |
| vehicle.speed = speed | |
| vehicle.travel = function () { | |
| vehicle.distance += vehicle.speed | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const roads = [ | |
| 'a-b', // ['a', 'b'] | |
| 'a-c', // ['a', 'c'] | |
| 'a-d', // ['a', 'd'] | |
| 'b-a', // ['b', 'a'] | |
| 'b-d', | |
| 'b-e', | |
| 'c-a', | |
| 'c-d', | |
| 'd-a', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Object containing budget categories and their initial budgets | |
| const categoryWiseBudget = { | |
| "Groceries": 2000, | |
| "Entertainment": 500, | |
| "Rent": 2000, | |
| "Utilities": 500, | |
| "Health": 2000, | |
| "Education": 1500, | |
| "Miscellaneous": 500 | |
| }; |