Skip to content

Instantly share code, notes, and snippets.

View AlvisonHunterArnuero's full-sized avatar
😀
Coding ? keepCoding : backToCoding

Alvison Hunter AlvisonHunterArnuero

😀
Coding ? keepCoding : backToCoding
View GitHub Profile
// 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
@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;
// 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();
/* 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".
/* ======================== 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,
};
@AlvisonHunterArnuero
AlvisonHunterArnuero / ThemeTextColors.ts
Last active October 24, 2024 16:14
This code defines a theme color system and retrieves hex color codes based on a given color name, logging the result.
const themeTextColorPalette = {
primary: "#3B5998",
secondary: "#8B9DC3",
dark: "#333333",
light: "#F7F7F7",
muted: "#CCC222",
} as const;
type ThemeTextColorName = keyof typeof themeTextColorPalette;
@AlvisonHunterArnuero
AlvisonHunterArnuero / main.js
Created October 16, 2024 18:30
ROCK PAPER SCISSORS - JAVASCRIPT PART
// 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');
@AlvisonHunterArnuero
AlvisonHunterArnuero / totalAmountOfPoints.js
Created October 8, 2024 06:35
Codewars Challenge: Total Amount Of Points
// 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);
@AlvisonHunterArnuero
AlvisonHunterArnuero / customStyles.css
Created October 3, 2024 05:47
Set the background image of a body of a html page to 50%, using pseudo-element ::before and the opacity: 0.5; property
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;
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]);