From 0d19c69a49eb6ca13f3bfc94aa81b36d3411042a Mon Sep 17 00:00:00 2001 From: Sherlyne Hernandez Date: Sun, 22 Mar 2026 19:13:15 -0500 Subject: [PATCH 1/2] Add JS solution to 3-21-first-tweet --- march-2026/3-21-first-tweet/first_tweet.js | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 march-2026/3-21-first-tweet/first_tweet.js diff --git a/march-2026/3-21-first-tweet/first_tweet.js b/march-2026/3-21-first-tweet/first_tweet.js new file mode 100644 index 0000000..15a13aa --- /dev/null +++ b/march-2026/3-21-first-tweet/first_tweet.js @@ -0,0 +1,23 @@ +// First Tweet 🐦 +// shercodes + +function tweetBalance(tweet) { + let charsLeft = 140; // Limit of characters + let count = 0; // Characters counter + let string = tweet.split(" "); // Words array + + for (let word of string) { + if (word.startsWith("@")) { // Usernames + count += 20; + } else if (word.startsWith("http://") || word.startsWith ("https://")) { // URLs + count += 23; + } else if (/\p{Emoji}/u.test(word)) { // Emojis + count += 2; + } else { // All other characters + count += word.length; + } + } + + count += string.length - 1; // Adds spaces + return charsLeft - count; +} \ No newline at end of file From 5f83378580b092b6e2d574c706052fb8804a44d7 Mon Sep 17 00:00:00 2001 From: Sherlyne Hernandez Date: Sun, 22 Mar 2026 19:13:58 -0500 Subject: [PATCH 2/2] Add JS solution to 3-22-water-day --- march-2026/3-22-water-day/water_day.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 march-2026/3-22-water-day/water_day.js diff --git a/march-2026/3-22-water-day/water_day.js b/march-2026/3-22-water-day/water_day.js new file mode 100644 index 0000000..f7becfc --- /dev/null +++ b/march-2026/3-22-water-day/water_day.js @@ -0,0 +1,20 @@ +// Water Day 💧 +// shercodes + +function leakyPipe(volume, leak, hours, threshold) { + let currentVolume = volume; // Initial volume + const lossRate = leak; // Percentage per hour + const iterations = hours; // Number of hours + let waterRemaining = 0; // Result + + for (let i = 0; i < iterations; i++) { + currentVolume = currentVolume * [1 - (lossRate / 100)]; // Calculates the volume after each hour passed. + if (currentVolume >= threshold) { + waterRemaining = Number(currentVolume.toFixed(2)); + } else { + waterRemaining = -1; + } + } + + return waterRemaining; +} \ No newline at end of file