Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
4c62400
updated 1-count.js with an explanation of line 3
JorvanW Jun 10, 2026
376a6b0
added answers to 0.js
Jun 27, 2026
2323e10
Added notes for 1.js
Jun 27, 2026
87fbee5
added notes for 2.js
Jun 27, 2026
57e3a65
added notes to 0.js
Jun 29, 2026
bf5c332
added answer to 0.js
Jun 29, 2026
4ca3f91
added notes to 1.js
Jun 29, 2026
185c7e7
added answers to 2.js
Jun 29, 2026
195189a
completed. 1-bmi
Jul 4, 2026
3f957a1
Answered the questions for 2-cases.js
Jul 4, 2026
b48031e
Added answers to the questions in the time-format.js file.
Jul 8, 2026
216221a
Created code for 1-get-angle-type.js
Jul 14, 2026
d10fc3c
fixed error in 'get-angle-types' and changed "let" to "function".
Jul 14, 2026
60638b4
wrote code for "is-proper-fraction" function and added test cases for it
Jul 14, 2026
2ac2702
Added code for 1-get-angle-type.test.js to include a test case for ea…
Jul 14, 2026
f8cf7cf
added code to test 2-is-proper-fraction.test.js
Jul 14, 2026
f3f69db
Add count function and tests
Jul 15, 2026
f6f3d1d
Remove CLI-Treasure-Hunt subproject from Sprint-2
Jul 15, 2026
0bdef75
Add functions and test for get-ordinal-number.js
Jul 15, 2026
630c502
removed unnecessary code and simplified it in excersie-1.js
Jul 15, 2026
55740a4
Removed dead code in exercise-2
Jul 15, 2026
6994606
Added code for repeat-string .js
Jul 17, 2026
e54bbd5
added code for 3-get-card-value.js
Jul 22, 2026
9aaaa7e
added tests for 3-get-card-value.test.js
Jul 22, 2026
7cacfb4
added notes for 3-get-card-value.js
Jul 22, 2026
a6131ab
updated formatting errors in 1-get-angle-types and 2-is-proper-faction
Jul 22, 2026
a85a823
updated code and added tests for repeat.str
Jul 22, 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
4 changes: 4 additions & 0 deletions Sprint-1/1-key-exercises/1-count.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ count = count + 1;

// Line 1 is a variable declaration, creating the count variable with an initial value of 0
// Describe what line 3 is doing, in particular focus on what = is doing

// = is assigning the value of 'count',
// 'let' is a declararation than enables its subject (count) to be changed
// line 3 is taking the current value in line 1 (0) and by using '=' it is reassigning the value of 'count' to equal itself plus 1
10 changes: 7 additions & 3 deletions Sprint-2/1-key-errors/0.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Predict and explain first...
// =============> write your prediction here
// =============> The fuction intends to capitalize the first letter of the input string
// from th left starting with the first character (str[0]).

// call the function capitalise with a string input
// interpret the error message and figure out why an error is occurring
Expand All @@ -9,5 +10,8 @@ function capitalise(str) {
return str;
}

// =============> write your explanation here
// =============> write your new code here
// =============> str has already been declared as a parameter function, so it cannot be redeclared within the function body. This will cause a syntax error. To fix this, we should use a different variable name for the new string we are creating.
// =============>
function capitalise(str) {
str = `${str[0].toUpperCase()}${str.slice(1)}`;
return str;
14 changes: 10 additions & 4 deletions Sprint-2/1-key-errors/1.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// Predict and explain first...

// Why will an error occur when this program runs?
// =============> write your prediction here
// Why will an error occur when this program runs?
// =============> decimalNumber is a constant variable, and cannot be changed.
// The code is attempting to change it which will cause an error.

// Try playing computer with the example to work out what is going on

Expand All @@ -14,7 +15,12 @@ function convertToPercentage(decimalNumber) {

console.log(decimalNumber);

// =============> write your explanation here
// =============> The code is attempting to get the percentage of decimalNumber

// Finally, correct the code to fix the problem
// =============> write your new code here
function convertToPercentage(decimalNumber) {
decimalNumber = 0.5;
const percentage = `${decimalNumber * 100}%`;
return percentage;
}
console.log (convertToPercentage(0.5));
12 changes: 8 additions & 4 deletions Sprint-2/1-key-errors/2.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,22 @@

// this function should square any number but instead we're going to get an error

// =============> write your prediction of the error here
// =============> num is not defined which causes an error.

function square(3) {
return num * num;
}

// =============> write the error message here
// =============> 1. "Uncaught SyntaxError: Unexpected number" Means the "3" is not valid there.
// 2. Uncaught SyntaxError: Illegal return statement. Means "num" has no idea of what it should be

// =============> explain this error message here

// Finally, correct the code to fix the problem

// =============> write your new code here
// =============> by adding square(num) the function will work when given a number
function square(num) {
return num * num;
}
console.log(square(3))


10 changes: 7 additions & 3 deletions Sprint-2/2-mandatory-debug/0.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
// Predict and explain first...

// =============> write your prediction here
// =============> Code is attempting to multiple a & b but there is no return value

function multiply(a, b) {
console.log(a * b);
}

console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);

// =============> write your explanation here
// =============> because there is no return value, the outcome stays as undefined while giving the answer
// to fix this, change "console.log" in the second row to "return"
//

// Finally, correct the code to fix the problem
// =============> write your new code here
function multiply(a, b) {
return (a * b);
}
13 changes: 10 additions & 3 deletions Sprint-2/2-mandatory-debug/1.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Predict and explain first...
// =============> write your prediction here
// =============> the function is attempting to add "a" & "b" together
// but the return is formatted wrong.

function sum(a, b) {
return;
Expand All @@ -8,6 +9,12 @@ function sum(a, b) {

console.log(`The sum of 10 and 32 is ${sum(10, 32)}`);

// =============> write your explanation here
// =============> because of the way line 6 and 7 is written the answer will be undefined.
//remove the semi colon from line 6 and then add line 7 to it.
// Finally, correct the code to fix the problem
// =============> write your new code here

function sum(a, b) {
return (a + b);
}

console.log(sum(10, 32))
22 changes: 17 additions & 5 deletions Sprint-2/2-mandatory-debug/2.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// Predict and explain first...

// Predict the output of the following code:
// =============> Write your prediction here
// =============> The function is trying to get the last digit of "num"
// but because on "const", the "num" is always locked to "103" leaving the return always "3"

const num = 103;

Expand All @@ -14,11 +15,22 @@ console.log(`The last digit of 105 is ${getLastDigit(105)}`);
console.log(`The last digit of 806 is ${getLastDigit(806)}`);

// Now run the code and compare the output to your prediction
// =============> write the output here
// =============> Just as predicted, the function is trying to get the last digit, which is always "3"
// Explain why the output is the way it is
// =============> write your explanation here
// =============> because of "const" the num is always locked to "103"
// Finally, correct the code to fix the problem
// =============> write your new code here

function getLastDigit(num) {
return num.toString().slice(-1);
}

console.log(`The last digit of 42 is ${getLastDigit(42)}`);
console.log(`The last digit of 105 is ${getLastDigit(105)}`);
console.log(`The last digit of 806 is ${getLastDigit(806)}`);


// This program should tell the user the last digit of each number.
// Explain why getLastDigit is not working properly - correct the problem
// Explain why getLastDigit is not working properly
// It's not working properly because of the "const num = 103"
// to fix, I have removed the line and added "(num)" after "function getLastDigit"
// In order to define what "num" is.
9 changes: 8 additions & 1 deletion Sprint-2/3-mandatory-implement/1-bmi.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,11 @@

function calculateBMI(weight, height) {
// return the BMI of someone based off their weight and height
}
}

function calculateBMI(weight, height) {
const bmi = weight / (height * height);
return parseFloat(bmi.toFixed(1));
}

console.log(calculateBMI(70, 1.73));
8 changes: 8 additions & 0 deletions Sprint-2/3-mandatory-implement/2-cases.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,11 @@
// You will need to come up with an appropriate name for the function
// Use the MDN string documentation to help you find a solution
// This might help https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase


function Capitalise(inputString) {
return inputString.toUpperCase()

}

Console.log(Capitalise("hello there"));
20 changes: 20 additions & 0 deletions Sprint-2/3-mandatory-implement/3-to-pounds.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,23 @@
// You will need to declare a function called toPounds with an appropriately named parameter.

// You should call this function a number of times to check it works for different inputs

const penceString = "399p";

const penceStringWithoutTrailingP = penceString.substring(
0,
penceString.length - 1
);

const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0");
const pounds = paddedPenceNumberString.substring(
0,
paddedPenceNumberString.length - 2
);

const pence = paddedPenceNumberString
.substring(paddedPenceNumberString.length - 2)
.padEnd(2, "0");

console.log(`£${pounds}.${pence}`);

10 changes: 5 additions & 5 deletions Sprint-2/4-mandatory-interpret/time-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@ function formatTimeDisplay(seconds) {
// Questions

// a) When formatTimeDisplay is called how many times will pad be called?
// =============> write your answer here
// =============> Pad will be called 3 times, once for totalHours, once for remainingMinutes, and once for remainingSeconds.

// Call formatTimeDisplay with an input of 61, now answer the following:

// b) What is the value assigned to num when pad is called for the first time?
// =============> write your answer here
// =============> The value will be 0

// c) What is the return value of pad is called for the first time?
// =============> write your answer here
// =============> The return value will be "00"

// d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer
// =============> write your answer here
// =============> The value assigned to num when pad is called for the last time in this program will be 1.Because it is the value of the remainingSeconds variable, which is calculated as 61 % 60 = 1.

// e) What is the return value of pad when it is called for the last time in this program? Explain your answer
// =============> write your answer here
// =============> The output is "01" because the pad function adds a leading zero to the number 1, resulting in a two-character string "01".
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,26 @@
// execute the code to ensure all tests pass.

function getAngleType(angle) {
{
if (angle > 0 && angle < 90) {
return "Acute angle";
}
if (angle === 90) {
return "Right angle";
}
if (angle > 90 && angle < 180) {
return "Obtuse angle";
}
if (angle === 180) {
return "Straight angle";
}
if (angle > 180 && angle < 360) {
return "Reflex angle";
}
return "Invalid angle";
}


// TODO: Implement this function
}

Expand All @@ -35,3 +55,6 @@ function assertEquals(actualOutput, targetOutput) {
// Example: Identify Right Angles
const right = getAngleType(90);
assertEquals(right, "Right angle");



Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
// After you have implemented the function, write tests to cover all the cases, and
// execute the code to ensure all tests pass.

function isProperFraction(numerator, denominator) {
// TODO: Implement this function
}

// The line below allows us to load the isProperFraction function into tests in other files.
// This will be useful in the "rewrite tests with jest" step.
Expand All @@ -31,3 +28,18 @@ function assertEquals(actualOutput, targetOutput) {

// Example: 1/2 is a proper fraction
assertEquals(isProperFraction(1, 2), true);

function isProperFraction(numerator, denominator) {
if (denominator === 0) {
return false;
}
if (numerator < denominator && numerator > 0) {
return true;
}
return false;
}
console.log(isProperFraction(2,3)); // true


module.exports = isProperFraction;

Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,31 @@
// execute the code to ensure all tests pass.

function getCardValue(card) {
// TODO: Implement this function
const suit = card.slice(-1);
const rank = card.slice(0, -1);

const validSuits = ["♠", "♥", "♦", "♣"];

if (!validSuits.includes(suit)) {
throw new Error("Invalid card");
}

if (rank === "A") {
return 11;
}

if (["J", "Q", "K"].includes(rank)) {
return 10;
}

if (["2", "3", "4", "5", "6", "7", "8", "9", "10"].includes(rank)) {
return Number(rank);
}

throw new Error("Invalid card");
}


// The line below allows us to load the getCardValue function into tests in other files.
// This will be useful in the "rewrite tests with jest" step.
module.exports = getCardValue;
Expand Down Expand Up @@ -52,3 +74,6 @@ try {
}

// What other invalid card cases can you think of?
// logging cards without suits to throw error


Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,36 @@ test(`should return "Acute angle" when (0 < angle < 90)`, () => {
});

// Case 2: Right angle
test(`should return "Right angle" when (angle === 90)`, () => {
// Test various acute angles, including boundary cases
expect(getAngleType(90)).toEqual("Right angle");
});

// Case 3: Obtuse angles
// Case 4: Straight angle
test(`should return "Obtuse angle" when (90 < angle < 180)`, () => {
// Test various obtuse angles, including boundary cases
expect(getAngleType(91)).toEqual("Obtuse angle");
expect(getAngleType(135)).toEqual("Obtuse angle");
expect(getAngleType(179)).toEqual("Obtuse angle");
});

// Case 4: Straight angle
test(`should return "Straight angle" when (angle === 180)`, () => {
// Test various acute angles, including boundary cases
expect(getAngleType(180)).toEqual("Straight angle");
});

// Case 5: Reflex angles
test(`should return "Reflex angle" when (180 < angle < 360)`, () => {
// Test various reflex angles, including boundary cases
expect(getAngleType(181)).toEqual("Reflex angle");
expect(getAngleType(270)).toEqual("Reflex angle");
expect(getAngleType(359)).toEqual("Reflex angle");
});

// Case 6: Invalid angles
test(`should return "Invalid angle" when (angle < 0 || angle > 360)`, () => {
// Test various invalid angles
expect(getAngleType(-1)).toEqual("Invalid angle");
expect(getAngleType(361)).toEqual("Invalid angle");
});
Loading
Loading