FullStack May 2023 Evening
FullStack May 2023 Evening
HTML ZIP
HTML-CSS Full ZIP
JavaScript Scratchpad #3
// // // let age = 80; // // // if (age >= 65) { // // // console.log('Drinks are free'); // // // } else if (age >= 21) { // // // console.log('You can enter and you can drink'); // // // } else if (age >= 18) { // // // console.log("You can enter but you can't drink"); // // // } else { // // // console.log("You can't enter"); // // // } // // // // if (age % 2 === 0) { // // // // console.log('Age is even'); // // // // } // // let password = 'hello [email protected]'; // // if (password.length >= 6) { // // if (password.indexOf(' ') !== -1) { // // console.log("Your password can't contain spaces"); // // } else { // // console.log('Valid password'); // // } // // } else { // // console.log('Invalid password'); // // } // // let loggedInUser = null; // // if (loggedInUser) { // // console.log('Welcome'); // // } else { // // console.log('Please login to view this page'); // // } // // let age = 80; // // if (age >= 18 && age < 21) { // // console.log("You can enter but you can't drink"); // // } else if (age >= 21 && age < 65) { // // console.log('You can enter and you can drink'); // // } else if (age >= 65) { // // console.log('Drinks are free'); // // } else { // // console.log("You can't enter"); // // } // let day = 3; // switch (day) { // case 1: // case 2: // case 3: // console.log('Wed'); // break; // case 4: // console.log('Thu'); // break; // case 5: // console.log('Fri'); // break; // case 6: // console.log('Sat'); // break; // case 7: // console.log('Sun'); // break; // default: // console.log('Invalid day code'); // } // let currentStatus = 'online'; // currentStatus === 'online' // ? console.log('Green') // : currentStatus === 'offline' // ? console.log('Red') // : console.log('Yellow'); // if (currentStatus === 'online') { // console.log('Green'); // } else if (currentStatus === 'offline') { // console.log('Red'); // } else { // console.log('Yellow'); // } let currentStatus = 'online'; let color = currentStatus === 'online' ? 'green' : currentStatus === 'offline' ? 'red' : yellow; // let color; // if (currentStatus === 'online') { // color = 'green'; // } else if (currentStatus === 'offline') { // color = 'red'; // } else { // color = 'yellow'; // }
Scratchpad #4 and #5
// const product1 = [ // 1, // 'iPhone 15', // 'Brand', // 'Some description...', // 200, // 100000, // true, // ]; const prod = { name: 'iPhone 15', brand: 'Apple', description: 'Some description...', inStock: 200, price: 100000, indexNo: 1, discounted: true, 100: 'hello world', 'the thing': NaN, }; console.log(prod.price); console.log(prod['100']); console.log(prod['the thing']); // // const prod = { // // name: 'iPhone 15', // // brand: 'Apple', // // description: 'Some description...', // // inStock: 200, // // price: 100000, // // indexNo: 1, // // discounted: true, // // }; // // prod.price = 200000; // // prod.inStock++; // // prod.helloWorld = 'HELLO WORLD'; // // delete prod.price; // // console.log(prod); // // // console.log(prod.price); // // // console.log(prod['inStock']); // // // console.log(prod.helloWorld); // const songs = [ // { // title: 'Song name', // artist: ['Name #1', 'Name #2'], // album: 'Album name', // trackLength: 2.45, // }, // { // title: 'Song name', // artist: ['Name #1', 'Name #2'], // album: 'Album name', // trackLength: 2.45, // }, // { // title: 'Song name', // artist: ['Name #1', 'Name #2'], // album: 'Album name', // trackLength: 2.45, // }, // ]; // for (let i = 0; i < 10; i--) { // console.log(i, 'Hello'); // } // for (let num = 1; num <= 10; num++) { // console.log(`${num}*${num}=${num * num}`); // } // for (let i = 100; i > 0; i--) { // console.log(i); // } // const nums = [12, 34, 56, 34, 78, 54, 23, 12]; // for (let i = 0; i < nums.length; i++) { // console.log(nums[i]); // } // const movies = [ // { movieName: 'Inception', rating: 3.8 }, // { movieName: 'Avengers', rating: 3.4 }, // { movieName: 'Iron Man', rating: 2.9 }, // ]; // for (let i = 0; i < movies.length; i++) { // const movie = movies[i]; // console.log(`${movie.movieName} has a rating of ${movie.rating}`); // } // const word = 'Hello World'; // let reversed = ''; // for (let i = word.length - 1; i >= 0; i--) { // reversed += word[i]; // } // console.log(reversed); // for (let i = 0; i < 5; i++) { // console.log(`${i} - OUTER LOOP`); // for (let j = 0; j < 5; j++) { // console.log(` ${j} - INNER LOOP`); // } // } // const gameBoard = [ // [4, 64, 8, 4], // [128, 32, 4, 16], // [16, 4, 4, 32], // [2, 16, 16, 2], // ]; // for (let i = 0; i < gameBoard.length; i++) { // // console.log(gameBoard[i]); // for (let j = 0; j < gameBoard[i].length; j++) { // console.log(gameBoard[i][j]); // } // } // for (let i = 0; i < 10; i++) { // console.log(i); // } // let j = 0; // while (j < 10) { // console.log(j); // j++; // } const target = Math.floor(Math.random() * 10) + 1; // 8 let guess = Math.floor(Math.random() * 10) + 1; // 3 while (target !== guess) { console.log(`Target: ${target} | Guess: ${guess}`); guess = Math.floor(Math.random() * 10) + 1; // 8 } console.log(`FINAL RESULT\nTarget: ${target} | Guess: ${guess}`); console.log('DONE');
Scratchpad #6
// // let names = [ // // ['test', 'test2', 'test3'], // // ['test4', 'test5', 'test6'], // // ]; // // for (let i = 0; i < names.length; i++) { // // for (let j = 0; j < names[i].length; j++) { // // console.log(names[i][j]); // // } // // } // // // // const target = Math.floor(Math.random() * 10) + 1; // // let guess = Math.floor(Math.random() * 10) + 1; // // while (true) { // // if (target === guess) { // // break; // // } // // console.log(`Target: ${target} | Guess: ${guess}`); // // guess = Math.floor(Math.random() * 10) + 1; // // } // // console.log(`FINAL RESULT\nTarget: ${target} | Guess: ${guess}`); // // for (let i = 0; i < 10; i++) { // // if (i === 5) { // // break; // // } // // console.log(i); // // } // const words = ['hello', 'world', 'test', 'something', 'else']; // // for (let i = 0; i < words.length; i++) { // // console.log(words[i]); // // } // // for (let word of words) { // // console.log(word); // // } // // for (let char of 'hello world'.split('').reverse().join('')) { // // console.log(char); // // } // // const matrix = [ // // [1, 4, 7], // // [9, 7, 2], // // [9, 4, 6], // // ]; // // for (let row of matrix) { // // for (let num of row) { // // console.log(num); // // } // // } // // const cats = ['fashion', 'mobiles', 'books']; // // const prods = ['tshirt', 'samsung', '1984']; // // for (let i = 0; i < cats.length; i++) { // // console.log(cats[i], prods[i]); // // } // const productPrices = { // Apple: 80000, // OnePlus: 50000, // Samsung: 90000, // }; // for (let key of Object.keys(productPrices)) { // console.log(key, productPrices[key]); // } // for (let key in productPrices) { // console.log(key, productPrices[key]); // } function num() { const num = Math.floor(Math.random() * 6) + 1; console.log(num); } num(); num(); num();