diff --git a/apps/cash-register/index.html b/apps/cash-register/index.html index 8f89ef3d..2b997768 100644 --- a/apps/cash-register/index.html +++ b/apps/cash-register/index.html @@ -12,7 +12,6 @@ Cash Register -
Cash Register Project
- - + + -
-
-

Total: $4.23

+

@@ -52,18 +43,7 @@

Cash Register Project

-
-

Change in Drawer

-

Pennies: $1.01

-

Nickels: $2.05

-

Dimes: $3.10

-

Quarters: $4.25

-

Ones: $90

-

Fives: $55

-

Tens: $20

-

Twenties: $60

-

Hundreds: $100

-
+
diff --git a/apps/cash-register/public/script.js b/apps/cash-register/public/script.js index dc0a7029..93b9254c 100644 --- a/apps/cash-register/public/script.js +++ b/apps/cash-register/public/script.js @@ -1,33 +1,24 @@ -// Do not change code below this line -const cid = [ - ['Penny', 1.01], - ['Nickel', 2.05], - ['Dime', 3.1], - ['Quarter', 4.25], - ['One', 90], - ['Five', 55], - ['Ten', 20], - ['Twenty', 60], - ['One hundred', 100] +let price = 3.26; +let cid = [ + ['PENNY', 1.01], + ['NICKEL', 2.05], + ['DIME', 3.1], + ['QUARTER', 4.25], + ['ONE', 90], + ['FIVE', 55], + ['TEN', 20], + ['TWENTY', 60], + ['ONE HUNDRED', 100] ]; -// Do not change code above this line -const message = document.getElementById('message'); const displayChangeDue = document.getElementById('change-due'); const cash = document.getElementById('cash'); const purchaseBtn = document.getElementById('purchase-btn'); -const newItemBtn = document.getElementById('new-btn'); -let newItemPrice = 4.23; - -const getNewPrice = () => { - displayChangeDue.innerHTML = ''; - cash.value = ''; - newItemPrice = Number((Math.random() * 200 + 1).toFixed(2)); - message.innerHTML = `Total: $${newItemPrice}`; -}; +const priceScreen = document.getElementById('price-screen'); +const cashDrawerDisplay = document.getElementById('cash-drawer-display'); const formatResults = (status, change) => { - displayChangeDue.innerHTML = `Status: ${status}`; + displayChangeDue.innerHTML = `

Status: ${status}

`; change.map( money => (displayChangeDue.innerHTML += `

${money[0]}: $${money[1]}

`) ); @@ -35,19 +26,20 @@ const formatResults = (status, change) => { }; const checkCashRegister = () => { - if (Number(cash.value) < newItemPrice) { - alert('Customer does not have enough money to purchase item'); + if (Number(cash.value) < price) { + alert('Customer does not have enough money to purchase the item'); cash.value = ''; return; } - if (Number(cash.value) === newItemPrice) { - displayChangeDue.innerHTML = 'No change due. Customer paid with exact cash'; + if (Number(cash.value) === price) { + displayChangeDue.innerHTML = + '

No change due - customer paid with exact cash

'; cash.value = ''; return; } - let changeDue = Number(cash.value) - newItemPrice; + let changeDue = Number(cash.value) - price; let reversedCid = [...cid].reverse(); let denominations = [100, 20, 10, 5, 1, 0.25, 0.1, 0.05, 0.01]; let result = { status: 'OPEN', change: [] }; @@ -59,7 +51,7 @@ const checkCashRegister = () => { ); if (totalCID < changeDue) { - return (displayChangeDue.innerHTML = 'Status: INSUFFICIENT_FUNDS'); + return (displayChangeDue.innerHTML = '

Status: INSUFFICIENT_FUNDS

'); } if (totalCID === changeDue) { @@ -79,12 +71,11 @@ const checkCashRegister = () => { } } if (changeDue > 0) { - return (displayChangeDue.innerHTML = 'Status: INSUFFICIENT_FUNDS'); + return (displayChangeDue.innerHTML = '

Status: INSUFFICIENT_FUNDS

'); } formatResults(result.status, result.change); - cash.value = ''; - return; + updateUI(result.change); }; const checkResults = () => { @@ -94,11 +85,41 @@ const checkResults = () => { checkCashRegister(); }; +const updateUI = change => { + const currencyNameMap = { + PENNY: 'Pennies', + NICKEL: 'Nickels', + DIME: 'Dimes', + QUARTER: 'Quarters', + ONE: 'Ones', + FIVE: 'Fives', + TEN: 'Tens', + TWENTY: 'Twenties', + 'ONE HUNDRED': 'Hundreds' + }; + // Update cid if change is passed in + if (change) { + change.forEach(changeArr => { + const targetArr = cid.find(cidArr => cidArr[0] === changeArr[0]); + targetArr[1] = parseFloat((targetArr[1] - changeArr[1]).toFixed(2)); + }); + } + + cash.value = ''; + priceScreen.textContent = `Total: $${price}`; + cashDrawerDisplay.innerHTML = `

Change in drawer:

+ ${cid + .map(money => `

${currencyNameMap[money[0]]}: $${money[1]}

`) + .join('')} + `; +}; + purchaseBtn.addEventListener('click', checkResults); + cash.addEventListener('keydown', e => { if (e.key === 'Enter') { checkResults(); } }); -newItemBtn.addEventListener('click', getNewPrice); +updateUI(); diff --git a/apps/cash-register/public/styles.css b/apps/cash-register/public/styles.css index ff9aa783..1e24e38a 100644 --- a/apps/cash-register/public/styles.css +++ b/apps/cash-register/public/styles.css @@ -49,12 +49,17 @@ h1 { .input-div { display: flex; + flex-direction: column; justify-content: center; align-items: center; flex-wrap: wrap; margin: 10px 0 20px; } +label { + font-size: 18px; +} + .user-input { height: 30px; padding: 10px; @@ -62,10 +67,6 @@ h1 { font-size: 15px; } -.change-title { - font-weight: bold; -} - .price-screen { border: 10px solid #99c9ff; background-color: black; @@ -100,18 +101,18 @@ h1 { padding-top: 20px; background-color: #99c9ff; height: 250px; - width: 350px; + width: 325px; } .btns-container { - width: 30%; + width: 25%; } .btn { border-radius: 10%; border: none; - width: 30px; - height: 30px; + width: 20px; + height: 20px; background-color: black; } @@ -129,10 +130,10 @@ h1 { border-width: 3px; } -.results { +.cash-drawer-display { font-size: 1.1rem; background-color: white; - width: 50%; + width: 55%; height: 95%; color: black; padding: 10px; @@ -141,7 +142,7 @@ h1 { .bottom-register { background-color: #99c9ff; height: 50px; - width: 400px; + width: 325px; margin-top: 10px; } diff --git a/apps/palindrome-checker/index.html b/apps/palindrome-checker/index.html index 9e7b30d4..e05d359c 100644 --- a/apps/palindrome-checker/index.html +++ b/apps/palindrome-checker/index.html @@ -12,7 +12,6 @@ Palindrome Checker -

Is it a Palindrome?

- - + + +

💡 - A palindrome is a word or phrase that can be read the same way - forwards and backwards. + A palindrome is a word or sentence that's spelled the same + way both forward and backward, ignoring punctuation, case, and + spacing.

- diff --git a/apps/palindrome-checker/public/script.js b/apps/palindrome-checker/public/script.js index 79839510..9102c205 100644 --- a/apps/palindrome-checker/public/script.js +++ b/apps/palindrome-checker/public/script.js @@ -1,30 +1,26 @@ const userInput = document.getElementById('text-input'); -const checkPalindromeBtn = document.getElementById('btn'); +const checkPalindromeBtn = document.getElementById('check-btn'); const resultDiv = document.getElementById('result'); const checkForPalindrome = input => { - const hasSpecialCharactersOrDigits = /[\W\d_]/.test(input); + const originalInput = input; // Store for later output if (input === '') { alert('Please input a value'); return; } - if (hasSpecialCharactersOrDigits === true) { - alert('Input should not include numbers and special characters'); - return; - } - // Remove the previous result. + // Remove the previous result resultDiv.replaceChildren(); - const lowerCaseStr = input.replace(/[^A-Z0-9]/gi, '').toLowerCase(); - let resultMsg = `${input} ${ + const lowerCaseStr = input.replace(/[^A-Za-z0-9]/gi, '').toLowerCase(); + let resultMsg = `${originalInput} ${ lowerCaseStr === [...lowerCaseStr].reverse().join('') ? 'is' : 'is not' } a palindrome.`; const pTag = document.createElement('p'); pTag.className = 'user-input'; - pTag.appendChild(document.createTextNode(resultMsg)); + pTag.innerHTML = resultMsg; resultDiv.appendChild(pTag); // Show the result. diff --git a/apps/palindrome-checker/public/styles.css b/apps/palindrome-checker/public/styles.css index ae69db98..e0de890f 100644 --- a/apps/palindrome-checker/public/styles.css +++ b/apps/palindrome-checker/public/styles.css @@ -46,6 +46,11 @@ body { box-shadow: 0 6px 6px #002ead; } +label { + color: #0a0a23; + margin-bottom: 20px; +} + .palindrome-btn { width: 90px; border: none; diff --git a/apps/pokemon-search-app/index.html b/apps/pokemon-search-app/index.html index 8d7f57fe..398e4c62 100644 --- a/apps/pokemon-search-app/index.html +++ b/apps/pokemon-search-app/index.html @@ -13,68 +13,67 @@ -

Pokémon Search App

-
- -
-
-
- - +
+ +

Pokémon Search App

+
+ +
+
+
+ + +
+
+ + +
+
+
-
- - +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
BaseStats
HP:
Attack:
Defense:
Sp. Attack:
Sp. Defense:
Speed:
- -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
BaseStats
HP:
Attack:
Defense:
Sp. Attack:
Sp. Defense:
Speed:
-
- + +
diff --git a/apps/pokemon-search-app/public/script.js b/apps/pokemon-search-app/public/script.js index 95edb56c..67611c1b 100644 --- a/apps/pokemon-search-app/public/script.js +++ b/apps/pokemon-search-app/public/script.js @@ -1,6 +1,6 @@ const pokemonID = document.getElementById('pokemon-id'); const pokemonName = document.getElementById('pokemon-name'); -const sprite = document.getElementById('sprite'); +const spriteContainer = document.getElementById('sprite-container'); const types = document.getElementById('types'); const height = document.getElementById('height'); const weight = document.getElementById('weight'); @@ -22,28 +22,26 @@ const getPokemon = async () => { const data = await response.json(); // Set Pokémon info - pokemonName.innerHTML = `${data.name.toUpperCase()}`; - pokemonID.innerHTML = `#${data.id}`; - weight.innerHTML = `Weight: ${data.weight}`; - height.innerHTML = `Height: ${data.height}`; - sprite.src = data.sprites.front_default; - sprite.alt = `${data.name} front default sprite`; + pokemonName.textContent = `${data.name.toUpperCase()}`; + pokemonID.textContent = `#${data.id}`; + weight.textContent = `Weight: ${data.weight}`; + height.textContent = `Height: ${data.height}`; + spriteContainer.innerHTML = ` + ${data.name} front default sprite + `; // Set stats - hp.innerHTML = data.stats[0].base_stat; - attack.innerHTML = data.stats[1].base_stat; - defense.innerHTML = data.stats[2].base_stat; - specialAttack.innerHTML = data.stats[3].base_stat; - specialDefense.innerHTML = data.stats[4].base_stat; - speed.innerHTML = data.stats[5].base_stat; + hp.textContent = data.stats[0].base_stat; + attack.textContent = data.stats[1].base_stat; + defense.textContent = data.stats[2].base_stat; + specialAttack.textContent = data.stats[3].base_stat; + specialDefense.textContent = data.stats[4].base_stat; + speed.textContent = data.stats[5].base_stat; // Set types - let typesHTML = ''; - - data.types.forEach(obj => { - typesHTML += `${obj.type.name}`; - }); - types.innerHTML = typesHTML; + types.innerHTML = data.types + .map(obj => `${obj.type.name}`) + .join(''); } catch (err) { resetDisplay(); alert('Pokémon not found'); @@ -51,28 +49,25 @@ const getPokemon = async () => { } }; +const resetDisplay = () => { + const sprite = document.getElementById('sprite'); + if (sprite) sprite.remove(); + + // reset stats + pokemonName.textContent = ''; + pokemonID.textContent = ''; + types.innerHTML = ''; + height.textContent = ''; + weight.textContent = ''; + hp.textContent = ''; + attack.textContent = ''; + defense.textContent = ''; + specialAttack.textContent = ''; + specialDefense.textContent = ''; + speed.textContent = ''; +}; + searchForm.addEventListener('submit', e => { e.preventDefault(); getPokemon(); }); - -function resetDisplay() { - // reset to default display if pokemon is not found - - // reset image src and alt - sprite.src = ''; - sprite.alt = ''; - - // reset stats - pokemonName.innerHTML = ''; - pokemonID.innerHTML = ''; - types.innerHTML = ''; - height.innerHTML = ''; - weight.innerHTML = ''; - hp.innerHTML = ''; - attack.innerHTML = ''; - defense.innerHTML = ''; - specialAttack.innerHTML = ''; - specialDefense.innerHTML = ''; - speed.innerHTML = ''; -} diff --git a/apps/pokemon-search-app/public/styles.css b/apps/pokemon-search-app/public/styles.css index ca21b4e0..d7ce1aee 100644 --- a/apps/pokemon-search-app/public/styles.css +++ b/apps/pokemon-search-app/public/styles.css @@ -21,26 +21,36 @@ img { /* Project styling */ body { + height: 100vh; font-family: sans-serif; - background-color: #0a0a23; + background-color: #1b1b32; color: #0a0a23; font-family: Verdana, Geneva, Tahoma, sans-serif; +} + +main { display: flex; flex-direction: column; align-items: center; + justify-content: center; +} + +.freecodecamp-logo { + height: 30px; + margin: 25px 0; } h1 { - color: #fff; - margin-top: 20px; + color: #f5f6f7; + font-size: 1.7em; + text-align: center; } .container { width: 325px; - margin: 30px 0; - background-color: #fff; - color: #000; - border: 1px solid #fff; + margin: 25px 0; + background-color: #f5f6f7; + border: 1px solid #f5f6f7; border-radius: 15px; box-shadow: 10px 10px 0px 0px rgba(223, 220, 220, 0.75); } @@ -52,12 +62,17 @@ h1 { } #search-form { + flex-wrap: wrap; margin: 10px 0; padding: 5px; border-radius: 8px 8px 0 0; gap: 10px; } +label { + align-self: center; +} + #search-input { height: 40px; padding-left: 10px; @@ -69,18 +84,12 @@ h1 { width: 80px; border-radius: 20px; text-align: center; - background-color: #a230d7; + background-color: #7f21ab; + color: #f5f6f7; outline: none; border: none; } -.sr-only { - position: absolute; - left: -10000px; - width: 1px; - height: 1px; -} - .output { margin: 10px 0; padding: 5px; @@ -92,8 +101,8 @@ h1 { .bottom-container { display: flex; flex-direction: column; - min-width: 400px; - min-height: 305px; + width: 100%; + min-height: 325px; } .top-container { @@ -114,11 +123,15 @@ h1 { font-size: 0.85rem; } +.sprite-container { + flex-grow: 2; + display: flex; + align-items: center; + justify-content: center; +} + #sprite { - margin: 20px 0; - min-width: 180px; - min-height: 180px; - align-self: center; + width: 180px; } #types { @@ -144,17 +157,17 @@ table { border-spacing: 0; width: 100%; font-size: 1 rem; - color: #fff; - background-color: #a230d7; + color: #f5f6f7; + background-color: #7f21ab; } th:nth-child(even), td:nth-child(even) { - border-left: 5px solid #fff; + border-left: 5px solid #f5f6f7; } tr { - border-bottom: 5px solid #fff; + border-bottom: 5px solid #f5f6f7; } td, @@ -238,6 +251,10 @@ th { } @media screen and (min-width: 550px) { + h1 { + font-size: 2em; + } + .container { width: 450px; } diff --git a/apps/roman-numeral-converter/index.html b/apps/roman-numeral-converter/index.html index 928d2397..960ad2c8 100644 --- a/apps/roman-numeral-converter/index.html +++ b/apps/roman-numeral-converter/index.html @@ -1,5 +1,5 @@ - + @@ -20,7 +20,7 @@

Roman Numeral Converter

diff --git a/apps/roman-numeral-converter/public/styles.css b/apps/roman-numeral-converter/public/styles.css index a85384a2..a42b4957 100644 --- a/apps/roman-numeral-converter/public/styles.css +++ b/apps/roman-numeral-converter/public/styles.css @@ -23,12 +23,8 @@ body { padding: 50px 20px; font-family: 'Lato', Helvetica, Arial, sans-serif; font-size: 18px; - background-color: #dfdfe2; - color: var(--gray-85); - display: flex; - flex-wrap: wrap; - align-items: center; - justify-content: center; + background-color: var(--gray-85); + color: var(--gray-05); } main { @@ -51,13 +47,14 @@ h1 { } form { - color: white; + color: var(--gray-05); margin: auto 25px; padding: 15px auto; - border: 3px solid var(--gray-90); + border: 3px solid var(--gray-05); text-align: center; width: 90%; - background-color: var(--gray-85); + max-width: 500px; + background-color: var(--gray-75); } fieldset { @@ -84,8 +81,7 @@ input { line-height: 1.4; color: white; background-color: var(--gray-90); - border-color: var(--gray-85); - border-radius: 0; + border: 1px solid var(--gray-05); outline: none; outline-style: none; } @@ -104,13 +100,13 @@ button { .output { color: white; - background-color: var(--gray-85); - border: 3px solid var(--gray-90); + background-color: var(--gray-75); + border: 3px solid var(--gray-05); font-size: 2.5rem; width: 90%; + max-width: 500px; min-height: 55px; margin-top: 25px; - border-radius: 0; padding: 15px; overflow-wrap: break-word; text-align: center; @@ -126,10 +122,3 @@ button { .hidden { display: none; } - -@media (min-width: 700px) { - form, - .output { - max-width: 450px; - } -} diff --git a/apps/telephone-number-validator/index.html b/apps/telephone-number-validator/index.html index ce8f4055..e36d41af 100644 --- a/apps/telephone-number-validator/index.html +++ b/apps/telephone-number-validator/index.html @@ -12,7 +12,6 @@ Telephone Number Validator -
freeCodeCamp Logo -

Is This a Valid Phone Number in the United States?

+

Telephone Number Validator

- - - + +
-