This file contains 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
// https://www.codewars.com/kata/586efc2dcf7be0f217000619/train/javascript | |
const reverseSlice = s => { | |
// First, split the string `s` into an array of characters, reverse the order, | |
// and join them back into a new string. | |
const reversedStr = s.split("").reverse().join(""); | |
// Iterate over the reversed string using the `map` method. | |
// On each iteration, return a substring that starts from the current index `i` | |
// to the end of `reversedStr`. This effectively creates a progressively smaller | |
// set of substrings, where each new element in the resulting array is a |
This file contains 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
@import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,200;1,14..32,200&family=Montserrat:ital,wght@0,100..900;1,100..900&display=swap'); | |
*, | |
*::before, | |
*::after { | |
box-sizing: border-box; | |
} | |
* { | |
margin: 0; |
This file contains 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
// Training JS #1 Create your first function | |
// https://www.codewars.com/kata/571ec274b1c8d4a61c0000c8 | |
const helloWorld = () => { | |
const str = 'Hello World!'; | |
console.log(str); | |
} | |
// Training #6 basic data-types and conditional statements | |
// https://www.codewars.com/kata/571f832f07363d295d001ba8/javascript | |
const trueOrFalse = val => Boolean(val).toString(); |
This file contains 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
/* Converts a time string between 12-hour and 24-hour formats. | |
* Made with ❤️ with TypeScript by Alvison Hunter - November 16th, 2024. | |
* | |
* @param {string} hour - The time string to convert. | |
* For 12-hour format, use "hh:mm:ss AM/PM". | |
* For 24-hour format, use "HH:mm:ss". | |
* @param {boolean} isMilitaryFormat - If `true`, converts from 12-hour to 24-hour format. | |
* If `false`, converts from 24-hour to 12-hour format. | |
* @returns {string} - The converted time string. | |
* For 24-hour format, returns "HH:mm:ss". |
This file contains 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
/* ======================== EXAMPLE ONE ======================== | |
| Made with ❤️ with TypeScript by Alvison Hunter - Nov 13th, 2024 | |
* ============================================================= | |
*/ | |
const productPrices = { | |
Apple: 1.5, | |
Banana: 0.5, | |
Orange: 1, | |
Mango: 2.5, | |
}; |
This file contains 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 themeTextColorPalette = { | |
primary: "#3B5998", | |
secondary: "#8B9DC3", | |
dark: "#333333", | |
light: "#F7F7F7", | |
muted: "#CCC222", | |
} as const; | |
type ThemeTextColorName = keyof typeof themeTextColorPalette; |
This file contains 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
// Instantiate all DOM elements referenced by their IDs | |
const playerChoice = document.getElementById('playerChoice'); | |
const pcChoice = document.getElementById('pcChoice'); | |
const winner = document.getElementById('winner'); | |
// Instantiate all DOM elements for event listeners | |
const rock = document.getElementById('rock'); | |
const paper = document.getElementById('paper'); | |
const scissors = document.getElementById('scissors'); |
This file contains 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
// CODEWAR CHALLENGE: Total amount of points | |
// Kata Link: https://www.codewars.com/kata/5bb904724c47249b10000131 | |
const points = (gamesResultsArr) => | |
gamesResultsArr.reduce((totalPoints, gameResults) => { | |
const [team1, team2] = gameResults.split(":").map(Number); | |
if (team1 === team2) return totalPoints + 1; | |
return totalPoints + (team1 > team2 ? 3 : 0); | |
}, 0); |
This file contains 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
body::before { | |
content: ""; | |
position: absolute; | |
top: 0; | |
left: 0; | |
right: 0; | |
bottom: 0; | |
background-image: url('place-your-image-url-here.jpg'); | |
background-size: cover; | |
background-position: center; |
This file contains 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 capitalize = (s: string): [string, string] => { | |
let arr01: string[] = []; | |
let arr02: string[] = []; | |
for (let i = 0; i < s.length; i++) { | |
if (i % 2 === 0) { | |
arr01.push(s[i].toUpperCase()); | |
arr02.push(s[i]); | |
} else { | |
arr01.push(s[i]); |
NewerOlder