Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
37f61c7
Fix render loop syntax error and display books on load
Apr 21, 2026
1279f89
Add object destructuring to introduceYourself function
Apr 21, 2026
af758d3
Filter Gryffindor members and teachers with pets using destructuring
Apr 21, 2026
70dad6b
Print takeout receipt using object destructuring
Apr 21, 2026
1c1a717
Implement ASCII cowsay CLI with default fallback message
Apr 21, 2026
433d3bb
Add readline prompt and default fallback to cowsay
Apr 21, 2026
6f81c61
Fix cowsay CLI argument handling and syntax errors"
Apr 21, 2026
47f2094
Add convertToNewRoman function for modern Roman numeral conversion
Apr 21, 2026
fb4cd7e
Add initial test for converting 1 to I
Apr 21, 2026
2689f12
Implement minimal convertToOldRoman function to pass first test
Apr 21, 2026
a2d2a04
Add initial test for converting 1 to old Roman numeral I
Apr 21, 2026
003029f
Implement sales function to total car prices by make
Apr 21, 2026
0b5add5
Implement factorial function using loop
Apr 21, 2026
9b628c5
Implement factorial function using loop
Apr 21, 2026
f902079
Implement average function excluding strings from calculation
Apr 21, 2026
4d7dcec
Add test for largest number function and verify array is unchanged
Apr 21, 2026
09b94c5
Add test for removing vowels from all words in array
Apr 21, 2026
1ae0ec8
Implement removeVowels function to remove lowercase vowels from word
Apr 21, 2026
c43aa61
Fix HTML validation errors and add language attribute"
Apr 21, 2026
2c80a9b
Clean up HTML validator issues"
Apr 21, 2026
851d249
Refactor book library code and address review feedback"
Apr 21, 2026
d0a6c0a
Add readline prompt to interactive cowsay solution
Apr 21, 2026
b67a1fe
Set up HTML structure for mini-weather app
Apr 21, 2026
4c83be7
Remove duplicate opacity declaration in thumbnail styles
Apr 21, 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
2 changes: 1 addition & 1 deletion Sprint-1/destructuring/exercise-1/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const personOne = {

// Update the parameter to this function to make it work.
// Don't change anything else.
function introduceYourself(___________________________) {
function introduceYourself({ name, age, favouriteFood }) {
console.log(
`Hello, my name is ${name}. I am ${age} years old and my favourite food is ${favouriteFood}.`
);
Expand Down
13 changes: 13 additions & 0 deletions Sprint-1/destructuring/exercise-2/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,16 @@ let hogwarts = [
occupation: "Teacher",
},
];
// Task 1
hogwarts.forEach(({ firstName, lastName, house }) => {
if (house === "Gryffindor") {
console.log(firstName, lastName);
}
});

// Task 2
hogwarts.forEach(({ firstName, lastName, occupation, pet }) => {
if (occupation === "Teacher" && pet !== null) {
console.log(firstName, lastName);
}
});
14 changes: 14 additions & 0 deletions Sprint-1/destructuring/exercise-3/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,17 @@ let order = [
{ itemName: "Hot Coffee", quantity: 2, unitPricePence: 100 },
{ itemName: "Hash Brown", quantity: 4, unitPricePence: 40 },
];
let totalPence = 0;

console.log("QTY ITEM TOTAL");

order.forEach(({ itemName, quantity, unitPricePence }) => {
let itemTotal = quantity * unitPricePence;
totalPence += itemTotal;

console.log(
`${quantity} ${itemName} ${(itemTotal / 100).toFixed(2)}`
);
});

console.log(`\nTotal: ${(totalPence / 100).toFixed(2)}`);
35 changes: 16 additions & 19 deletions challenges/challenge-cowsay-two/solution1.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,27 @@
// =================
// Stripped down cowsayer CLI,
// Stripped down cowsayer CLI,
// no libraries
// https://nodejs.dev/learn/nodejs-accept-arguments-from-the-command-line
// =================

// 1. Accept arguments

// how will you accept arguments?

// 2. Make supplies for our speech bubble

let topLine = '_';
let bottomLine = '-';
let saying = '';
let topLine = "_";
let bottomLine = "-";
let saying = process.argv[2] || "Mooooo";

// 3. Make a cow that takes a string

function cowsay(saying) {
// how will you make the speech bubble contain the text?

// where will the cow picture go?

// how will you account for the parameter being empty?

let line = "_".repeat(saying.length + 2);
let bottom = "-".repeat(saying.length + 2);

console.log(` ${line} `);
console.log(`< ${saying} >`);
console.log(` ${bottom} `);
console.log(` \\ ^__^`);
console.log(` \\ (oo)\\_______`);
console.log(` (__)\\ )\\/\\`);
console.log(` ||----w |`);
console.log(` || ||`);
}

//4. Pipe argument into cowsay function and return a cow

// how will you log this to the console?
cowsay(saying);
35 changes: 20 additions & 15 deletions challenges/challenge-cowsay-two/solution2.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
// =================
// Stripped down cowsayer CLI,
// no libraries or arguments
// https://nodejs.dev/learn/accept-input-from-the-command-line-in-nodejs
// =================

// 1. Make a command line interface.

// 2. Make supplies for our speech bubble

// 3. Make a cow that takes a string
const readline = require("readline");
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});

const cow = (saying) => {
// how did you make the cow before?
}
let line = "_".repeat(saying.length + 2);
let bottom = "-".repeat(saying.length + 2);

// 4. Use readline to get a string from the terminal
// (with a prompt so it's clearer what we want)
console.log(` ${line} `);
console.log(`< ${saying} >`);
console.log(` ${bottom} `);
console.log(` \\ ^__^`);
console.log(` \\ (oo)\\_______`);
console.log(` (__)\\ )\\/\\`);
console.log(` ||----w |`);
console.log(` || ||`);
};
rl.question("What would you like the cow to say? ", function (answer) {
cow(answer || "Mooooo");
rl.close();
});
2 changes: 0 additions & 2 deletions challenges/challenge-weather-app/assets/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@
animation: 0.25s forwards fade-in;

display: block;
opacity: 0;
object-fit: cover;

flex: 0 0 auto;
Expand All @@ -125,7 +124,6 @@
background: rgba(0, 0, 0, 0.5);
}


/* Credits
------------------------------------------------------------------------------*/
.info {
Expand Down
96 changes: 50 additions & 46 deletions challenges/challenge-weather-app/index.html
Original file line number Diff line number Diff line change
@@ -1,49 +1,53 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">

<title>Meteoropolis</title>
<link rel="stylesheet" href="assets/globals.css">
<link rel="stylesheet" href="assets/styles.css">
</head>

<body>
<!-- Structure -->
<main class="content">
<header class="header">
<h1 class="title">
<i>Meteor</i>
<i>opolis</i>
</h1>
</header>

<figure class="photo" id="photo"></figure>

<div class="info">
<p class="info__item info__item--conditions" id="conditions"></p>
<p class="info__item info__item--credits">
<a href="#" id="credit-user"></a>
<span>on</span>
<a href="#" id="credit-platform">Unsplash</a>
</p>
</div>

<div class="thumbs" id="thumbs"></div>

<div class="controls">
<form class="search" id="search">
<label class="search__label" for="search-tf">City</label>
<input class="search__input" id="search-tf" name="city" placeholder="Enter city name" autocomplete="city" />
<button class="btn search__btn">Go</button>
</form>
</div>
</main>

<!-- JS goes here -->
</body>

<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />

<title>Meteoropolis</title>
<link rel="stylesheet" href="assets/globals.css" />
<link rel="stylesheet" href="assets/styles.css" />
</head>

<body>
<!-- Structure -->
<main class="content">
<header class="header">
<h1 class="title">
<i>Meteor</i>
<i>opolis</i>
</h1>
</header>

<figure class="photo" id="photo"></figure>

<div class="info">
<p class="info__item info__item--conditions" id="conditions"></p>
<p class="info__item info__item--credits">
<a href="#" id="credit-user"></a>
<span>on</span>
<a href="#" id="credit-platform">Unsplash</a>
</p>
</div>

<div class="thumbs" id="thumbs"></div>

<div class="controls">
<form class="search" id="search">
<label class="search__label" for="search-tf">City</label>
<input
class="search__input"
id="search-tf"
name="city"
placeholder="Enter city name"
autocomplete="city"
/>
<button type="submit" class="btn search__btn">Go</button>
</form>
</div>
</main>

<!-- JS goes here -->
</body>
</html>
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
function convertToNewRoman(n) {}
function convertToNewRoman(n) {
const romanNumerals = [
[1000, "M"],
[900, "CM"],
[500, "D"],
[400, "CD"],
[100, "C"],
[90, "XC"],
[50, "L"],
[40, "XL"],
[10, "X"],
[9, "IX"],
[5, "V"],
[4, "IV"],
[1, "I"],
];

let result = "";

for (let [value, symbol] of romanNumerals) {
while (n >= value) {
result += symbol;
n -= value;
}
}

return result;
}
module.exports = convertToNewRoman;
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ let convertToNewRoman = require("./convert-to-new-roman");

test("returns I if passed 1 as an argument", function () {
// Arrange
const input = 1;

// Act
const result = convertToNewRoman(input);

// Assert
expect(result).toBe("I");
});
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
function convertToOldRoman(n) {}
function convertToOldRoman(n) {
return "I";
}

module.exports = convertToOldRoman;
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ let convertToOldRoman = require("./convert-to-old-roman");

test("returns I if passed 1 as an argument", function () {
// Arrange
const input = 1;

// Act
const result = convertToOldRoman(input);

// Assert
expect(result).toBe("I");
});
14 changes: 13 additions & 1 deletion challenges/unit-testing/passing-tests/car-sales/car-sales.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
function sales(carsSold) {}
function sales(carsSold) {
let totals = {};

for (let car of carsSold) {
if (totals[car.make]) {
totals[car.make] += car.price;
} else {
totals[car.make] = car.price;
}
}

return totals;
}

module.exports = sales;
16 changes: 7 additions & 9 deletions challenges/unit-testing/passing-tests/factorial/factorial.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
// int is an integer
// a factorial is the product of all non-negative integers
// less than or equal to the iniital number.
function factorial(int) {
let result = 1;

// for example the factorial of 5 is 120
// 120 = 1 * 2 * 3 * 4 * 5
for (let i = 1; i <= int; i++) {
result *= i;
}

// calculate and return the factorial of int
// note: factorial of 0 is 1

function factorial(int) {}
return result;
}

module.exports = factorial;
14 changes: 13 additions & 1 deletion challenges/unit-testing/passing-tests/get-average/get-average.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@
// return the average of all the numbers
// be sure to exclude the strings

function average(numbers) {}
function average(numbers) {
let sum = 0;
let count = 0;

for (let item of numbers) {
if (typeof item === "number") {
sum += item;
count++;
}
}

return sum / count;
}

module.exports = average;
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ let getLargestNumber = require("./largest-number");

test("returns largest number in array", function () {
// Arrange
let input = [3, 21, 88, 4, 36];
let original = [...input];

// Act
let result = getLargestNumber(input);

// Assert
expect(result).toBe(88);
expect(input).toEqual(original);
});

// example
// input: [3, 21, 88, 4, 36];
// expected: 88;

// also test that the original array hasn't changed
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,3 @@ function removeVowelsFromWords(words) {
}

module.exports = removeVowelsFromWords;

/*
input: ["Irina", "Etza", "Daniel"]
expected output: ["rn", "tz", "Dnl"]
*/
Loading
Loading