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
| #!/bin/bash | |
| function lazygit() { | |
| git add -A | |
| git commit -m "$1" | |
| git push origin main | |
| } |
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
| #!/bin/bash | |
| # create a variable to keep track if we want to keep using the calculator | |
| runCalculator="y" | |
| # while the value of `runCalculator` is 'y' for 'yes', run the calculator functionality | |
| # use `;` between statements to terminate one and begin the other, or simply move the second statement to the following line | |
| while [ $runCalculator = "y" ]; do | |
| # clear the command line for a cleaner experience |
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 email = /^(?<username>[\w\.-]+)@(?<domain>\w+)\.(?<extension>\w{3})(?<loc>\.\w{2,8})?$/ | |
| // Email RegEx | |
| // (username) @ (domain) . (extension) (.again) | |
| // 1. any letters, numbers, dots and/or hyphens | |
| // 2. any letters, numbers, and/or hyphens | |
| // 3. any letters | |
| // 4. a dot (.) then any letters |
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 str = 'coding money'; | |
| const str2 = 'money coding'; | |
| const str3 = 'RAIL! SAFETY!'; | |
| const str4 = 'fairy tales'; | |
| function anagram(str1, str2) { | |
| const str1Arr = str1.toLowerCase().replace(/[\W]/g,'').split('').sort(); | |
| console.log(str1Arr); | |
| const str2Arr = str2.toLowerCase().replace(/[\W]/g,'').split('').sort(); |
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
| function chunk(array, size) { | |
| return array.reduce((acc, val, i) => { | |
| if (i % size === 0) { | |
| acc.push([]); | |
| console.log(acc); | |
| console.log(i); | |
| } | |
| console.log(val); | |
| acc[acc.length - 1].push(val); | |
| return acc; |
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 str = 'abbccccddd'; | |
| function maxChar(str) { | |
| let charMap = {}; | |
| let max = 0; | |
| let char = ''; | |
| for (char of str) { | |
| charMap[char] = ++charMap[char] || 1 |
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
| /* Top 5 most popular | |
| 5: What is the difference between GET and POST when making an AJAX request? | |
| GET and POST are two different HTTP requests | |
| Use GET when retrieving data from the server | |
| Use POST when sending data from the client to the server to create/update a resource | |
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 phoneRegEx = /(?:(?<international>\+1)[ -])?\(?(?<areacode>\d{3})\)?[ -]?(?<prefix>\d{3})[ -]?(?<line_number>\d{4})/ | |
| // 1234567890 | |
| // 123-456-7890 | |
| // 123 456 7890 | |
| // (123) 456 7890 | |
| // +1 123 456 7890 |
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
| /* Write a function (createCounter). It should accept an intitial integer (init). | |
| It should return an object with three functions. | |
| The three functions are: | |
| -- increment() increases the current value by 1 and then returns it | |
| -- decrement() reduces the current value by 1 and then returns it | |
| -- reset() sets the current value to (init) and then returns it. | |
| */ | |
| const createCounter = function(init) { |
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
| function fizzBuzz(num) { | |
| let output = []; | |
| for (let i = 1; i <= num; i++) { | |
| if (i % 3 === 0 && i % 5 === 0) { | |
| output.push('FizzBuzz'); | |
| } else if (i % 3 === 0) { | |
| output.push('Fizz'); | |
| } else if (i % 5 === 0) { | |
| output.push('Buzz'); |
OlderNewer