Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
3cd43c8
Greetings bot variables practice.
codebydoble Jan 6, 2026
57039cc
Trivia bot small changes
codebydoble Jan 6, 2026
20466f3
Sentence maker. In this lab, you will create two different stories us…
codebydoble Jan 6, 2026
8d60310
JS course: Prompt section.
codebydoble Jan 7, 2026
1f78880
Workshop JS build a teacher chatbot
codebydoble Jan 8, 2026
fa966d2
Workshop, working with the includes() and slice() methods.
codebydoble Jan 8, 2026
76bfb95
Workshop string trim, trimstart, trimend, tolowercase, touppercase, s…
codebydoble Jan 9, 2026
18581d0
Add string transformation examples with replace and repeat methods
codebydoble Jan 11, 2026
b0b8974
Update README to include exercises for string manipulation projects
codebydoble Jan 11, 2026
ff50eb2
Add comprehensive advanced string manipulation exercises to README
codebydoble Jan 11, 2026
ddcd63e
String Exercises solved - JavaScript Mastery from Claude AI.
codebydoble Feb 16, 2026
b48419c
Score and review from Claude AI: 85/100 pts.
codebydoble Feb 16, 2026
215c984
Fix excersices after review. Practice and learn.
codebydoble Mar 9, 2026
1004b85
Add best practice regExp in Javascript.
codebydoble Mar 9, 2026
b34e91a
Add advanced string mastery exam with theoretical questions and codin…
codebydoble Apr 23, 2026
1e54a5d
Merge pull request #25 from codebydoble/feature-string-exercises
codebydoble Apr 23, 2026
08ae188
Add various function implementations and corresponding lab descriptio…
codebydoble Apr 29, 2026
c382be1
Merge pull request #26 from codebydoble/functions-section
codebydoble Apr 29, 2026
a8b564a
Add Golf Score Translator and Lunch Picker Program implementations wi…
codebydoble Apr 29, 2026
e7d1449
Merge pull request #27 from codebydoble/array-section
codebydoble Apr 29, 2026
4294afc
Array y functions exam. Implement closure patterns: memoize, curry, o…
codebydoble May 20, 2026
370a94f
Merge pull request #28 from codebydoble/function-array-exam
codebydoble May 20, 2026
516d64f
feat: Add comprehensive Vanilla JS example with closures, event handl…
codebydoble May 20, 2026
8d5138d
Merge pull request #29 from codebydoble/functions-study
codebydoble May 20, 2026
9357337
feat: Add solutions for objects and loops exam, including Vec class, …
codebydoble Jul 4, 2026
60a0220
Merge pull request #30 from codebydoble/objects-section
codebydoble Jul 4, 2026
12c543e
feat: Add various algorithms and their documentation for loops sectio…
codebydoble Jul 4, 2026
539c92a
feat: Add various JavaScript functions for fundamental algorithms
codebydoble Jul 4, 2026
6ef76ed
Merge pull request #31 from codebydoble/js-fundamentals
codebydoble Jul 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
594 changes: 594 additions & 0 deletions fullstack/javascript/1-variables-strings/exercises/README.md

Large diffs are not rendered by default.

1,148 changes: 1,148 additions & 0 deletions fullstack/javascript/1-variables-strings/exercises/script-claude-ai.js

Large diffs are not rendered by default.

195 changes: 195 additions & 0 deletions fullstack/javascript/1-variables-strings/exercises/script-regexp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
/*
1. Remove all non-digits
str.replace(/\D/g, '')
"abc123def456" → "123456"

2. Remove all non-alphanumeric (keep letters and numbers)
str.replace(/[^\w]/g, '')
"hello-world!" → "helloworld"

3. Remove punctuation (keep letters, numbers, spaces)
str.replace(/[^\w\s]/g, '')
"Hello, world!" → "Hello world"

4. Split by one or more spaces
str.split(/\s+/)
"hello world" → ["hello", "world"]

5. Match email pattern
/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g

6. Match hashtags
/#(\w+)/g

7. Match text between delimiters (non-greedy)
/\[(.*?)\]/g
"[abc] [def]" → matches "abc" and "def" separately

8. Check if contains uppercase
/[A-Z]/.test(str)

9. Check if contains number
/\d/.test(str)

10. Escape RegExp special characters
str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')


Challenge for You
Find potential bugs in these other solutions I gave you:
Exercise 13: Title Case Converter
javascript// Does this handle ALL edge cases?
const prevWord = words[index - 1];
if (prevWord && prevWord.endsWith(':')) {
return capitalize(word);
}
What if:

Input: "title:no space after colon"
Input: "title: :double colon"
Input: "title:)emoticon"

Exercise 16: URL Parameter Extractor
javascript
const queryString = url.slice(queryIndex + 1);
What if:

Input: "https://example.com?"
Input: "https://example.com?key=value=extra"
Input: "https://example.com?key="

Test these and let me know if you find bugs!
*/

/* Testing */
const myName = " Yoandy 88 "
console.log("Eliminando no digitos:" + myName.replace(/\D/g, ""))
console.log("Eliminando digitos:" + myName.replace(/\d/g, ""))
console.log("Eliminando espacios:" + myName.replace(/\s+/g, ""))
console.log("Eliminando letras - punctuation:" + "Hello, world 22587!".replace(/\D/g, ""))

/*
Exercise 6: Credit Card Masker
**Difficulty:** Easy
**Objective:** Mask credit card number showing only last 4 digits
Requirements:
[x] - Accept string of 16 digits
[x] - Replace first 12 digits with *
[x] - Keep spaces if present
[x] - "1234 5678 9012 3456" becomes "**** **** **** 3456"
*/

/**
* Function that receive a credit card number and apply a mask showing only last 4 digits.
* @param {String} cardNumber credit card number with 16 or 19 digits.
* @returns credit card number showing only last 4 digits.
*/
function maskCreditCard(cardNumber) {
// Keep numbers only
//const cleaned = cardNumber.replace(/[^0-9]/g, "")
const cleaned = cardNumber.replace(/\D/g, "")
// check length
if (cleaned.length !== 16) {
console.log("only digits:" + cleaned)
return "Wrong credit card number"
}
// Mask first 12 digits
const masked = "*".repeat(12) + cleaned.slice(-4)
// Re-add spaces if original had them
if (cardNumber.includes(" ")) {
return masked.match(/.{1,4}/g).join(" ")
}
return masked
}

// Test cases:
console.log(`Exercise 6: Credit Card Masker`)
console.log(maskCreditCard("1234567899876549")) // "************3456"
console.log(maskCreditCard("1234 5678 9012 3456")) // "**** **** **** 3456"
// Valid cases
console.log(maskCreditCard("1234567890123456")) // "************3456"
console.log(maskCreditCard("1234 9632 9012 3456")) // "**** **** **** 3456"
console.log(maskCreditCard("4532-1488-0343-6467")) // "**** **** **** 6467"

// Invalid cases
console.log(maskCreditCard("yoandydobleshola")) // "Wrong credit card number"
console.log(maskCreditCard("123")) // "Wrong credit card number"
console.log(maskCreditCard("abcd1234efgh5678")) // "Wrong credit card number"
console.log(maskCreditCard("")) // "" (string vacío)*/
console.log("\n==================================\n")

/*
Find potential bugs in these other solutions I gave you:
Exercise 13: Title Case Converter
javascript// Does this handle ALL edge cases?
const prevWord = words[index - 1];
if (prevWord && prevWord.endsWith(':')) {
return capitalize(word);
}
What if:

Input: "title:no space after colon"
Input: "title: :double colon"
Input: "title:)emoticon"
Exercise 13: Title Case Converter (Advanced)
Difficulty: Hard
Objective: Convert to title case with English grammar rules
*/

// Requirements:
// [x] - Capitalize first and last word always
// [x] - Capitalize all words except: a, an, the, and, but, or, for, nor, on, at, to, by, in
// [x] - Articles after colon (:) should be capitalized
// [x] - "the quick brown fox" → "The Quick Brown Fox"
// [x] - "a tale of two cities" → "A Tale of Two Cities"

/**
* Converts text to title case following English grammar rules
* @param {string} text - Text to convert
* @returns {string} Title-cased text
*/
function toTitleCase(text) {
// Words that should remain lowercase (unless first/last/after colon)
const exceptions = new Set(["a", "an", "the", "and", "but", "or", "for", "nor", "on", "at", "to", "by", "in", "of"])

const words = text.trim().toLowerCase().split(/\s+/)

return words
.map((word, index) => {
// Always capitalize first and last word
if (index === 0 || index === words.length - 1) {
return capitalize(word)
}

// Check if previous word ended with colon
const prevWord = words[index - 1]
if (prevWord && prevWord.endsWith(":")) {
return capitalize(word)
}

// Capitalize unless it's an exception word
return exceptions.has(word) ? word : capitalize(word)
})
.join(" ")
}

/**
* Capitalizes first letter of a word
* @param {string} word - Word to capitalize
* @returns {string} Capitalized word
*/
function capitalize(word) {
return word.charAt(0).toUpperCase() + word.slice(1)
}
// Test cases:
console.log(`Exercise 13: Title Case Converter (Advanced)`)
//console.log(toTitleCase("the lord of the rings"))
// "The Lord of the Rings"
//console.log(toTitleCase("thE an THE"))
// "The an The"
//console.log(toTitleCase("title:no space after colon"))
//console.log(toTitleCase("title: :double colon"))
console.log(toTitleCase("title:'-(emotic:(on"))
// "Javascript"
//console.log(toTitleCase(" Array sentence: just finished an amazing dayx. "))
console.log("\n==================================\n")
Loading