Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
84e3bca
First 3 exercises of sprint 1 are completed.
eminakturk Jun 25, 2025
3c9fb3a
Key exercise part is done with this commit
eminakturk Jun 25, 2025
c882576
Mandatory errors 0 and 1.js is solved.
eminakturk Jun 25, 2025
8ccf3b2
Mandatory-errors part is finished.
eminakturk Jun 25, 2025
d0c0bd7
until time format is finished.
eminakturk Jun 27, 2025
721fe57
finishing touch
eminakturk Jun 27, 2025
f2f56be
first answer is increment added answer comment section.
eminakturk Jul 7, 2025
421bdf2
random.js solution part is fixed.
eminakturk Jul 7, 2025
f978685
4.js syntax error is fixed.
eminakturk Jul 7, 2025
ed5a1b5
identified 5th function calls and fixed the programming term with mor…
eminakturk Jul 7, 2025
e57d878
.padEnd is deleted as I've reviewed that It's not necessary to have it.
eminakturk Jul 7, 2025
f6d89d1
0.js error fixed
eminakturk Jul 7, 2025
5666561
key errors part is finished
eminakturk Jul 7, 2025
494b2e5
mandatory debug part is solved.
eminakturk Jul 7, 2025
8cc0f09
mandatory implement part is done.
eminakturk Jul 7, 2025
5feaf2e
mandatory interpret part is done.
eminakturk Jul 7, 2025
11f7873
Delete Sprint-1/1-key-exercises/1-count.js
eminakturk Aug 8, 2025
29a5ae7
Delete Sprint-1/1-key-exercises/2-initials.js
eminakturk Aug 8, 2025
273fafc
Delete Sprint-1/1-key-exercises/3-paths.js
eminakturk Aug 8, 2025
cd0d666
Delete Sprint-1/1-key-exercises/4-random.js
eminakturk Aug 8, 2025
7e7357b
Delete Sprint-1/2-mandatory-errors/0.js
eminakturk Aug 8, 2025
1c772e8
Delete Sprint-1/2-mandatory-errors/1.js
eminakturk Aug 8, 2025
aca4c2b
Delete Sprint-1/2-mandatory-errors/2.js
eminakturk Aug 8, 2025
eb244fd
Delete Sprint-1/2-mandatory-errors/3.js
eminakturk Aug 8, 2025
c66c5c6
Delete Sprint-1/2-mandatory-errors/4.js
eminakturk Aug 8, 2025
fde1ec2
Delete Sprint-1/3-mandatory-interpret/1-percentage-change.js
eminakturk Aug 8, 2025
9ba099d
Delete Sprint-1/3-mandatory-interpret/2-time-format.js
eminakturk Aug 8, 2025
70b7e45
Delete Sprint-1/3-mandatory-interpret/3-to-pounds.js
eminakturk Aug 8, 2025
d60ad83
fixes.
eminakturk Aug 20, 2025
db5ec04
Merge branch 'coursework/sprint-2' of https://github.com/eminakturk/M…
eminakturk Aug 20, 2025
203af12
Merge branch 'main' into coursework/sprint-2
eminakturk Aug 20, 2025
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
6 changes: 0 additions & 6 deletions Sprint-1/1-key-exercises/1-count.js

This file was deleted.

11 changes: 0 additions & 11 deletions Sprint-1/1-key-exercises/2-initials.js

This file was deleted.

23 changes: 0 additions & 23 deletions Sprint-1/1-key-exercises/3-paths.js

This file was deleted.

9 changes: 0 additions & 9 deletions Sprint-1/1-key-exercises/4-random.js

This file was deleted.

2 changes: 0 additions & 2 deletions Sprint-1/2-mandatory-errors/0.js

This file was deleted.

4 changes: 0 additions & 4 deletions Sprint-1/2-mandatory-errors/1.js

This file was deleted.

5 changes: 0 additions & 5 deletions Sprint-1/2-mandatory-errors/2.js

This file was deleted.

9 changes: 0 additions & 9 deletions Sprint-1/2-mandatory-errors/3.js

This file was deleted.

2 changes: 0 additions & 2 deletions Sprint-1/2-mandatory-errors/4.js

This file was deleted.

22 changes: 0 additions & 22 deletions Sprint-1/3-mandatory-interpret/1-percentage-change.js

This file was deleted.

25 changes: 0 additions & 25 deletions Sprint-1/3-mandatory-interpret/2-time-format.js

This file was deleted.

27 changes: 0 additions & 27 deletions Sprint-1/3-mandatory-interpret/3-to-pounds.js

This file was deleted.

19 changes: 17 additions & 2 deletions Sprint-2/1-key-errors/0.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
// Predict and explain first...
// =============> write your prediction here
// I predict the code is for capitalising the first letter of a string.


// call the function capitalise with a string input
// interpret the error message and figure out why an error is occurring

function capitalise(str) {
// the error is "The symbol "str" has already been declared."

/* function capitalise(str) {
let str = `${str[0].toUpperCase()}${str.slice(1)}`;
return str;
}

*/
// =============> write your explanation here
// Error occurs because the str was mentioned as a parameter in the definition which is already a variable name in the function body.

// =============> write your new code here

function capitalise(str) {
const capitalisedStr = `${str[0].toUpperCase()}${str.slice(1)}`;
return capitalisedStr;
}

// to call the function :

console.log(capitalise("naber?")); // Output: "Naber?"
15 changes: 12 additions & 3 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...
// program is made for converting a decimal number into a percentage.

// Why will an error occur when this program runs?
// =============> write your prediction here
// =============> I think error would occur because decimalNumber is declared twice.

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

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

console.log(decimalNumber);

// =============> write your explanation here
// =============> to fix the problem I will remove the second declaration of decimalNumber and use the parameter instead.

// Finally, correct the code to fix the problem
// =============> write your new code here
// =============>
function convertToPercentage(decimalNumber) {
const percentage = `${decimalNumber * 100}%`;

return percentage;
}

// to call the function
console.log(convertToPercentage(1)); // Output: "100%"
14 changes: 10 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,24 @@

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

// =============> write your prediction of the error here
// =============> My prediction is that error occurs because function trying to use a number as a function.

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

// =============> write the error message here
// =============> Expected identifier but found "3"

// =============> explain this error message here
// =============> While program waiting for an identifier, it found a number instead.

// Finally, correct the code to fix the problem

// =============> write your new code here
// =============>
function square(num) {
return num * num;
}

// to call the function
console.log(square(9)); // Output: 81


19 changes: 13 additions & 6 deletions Sprint-2/2-mandatory-debug/0.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
// Predict and explain first...

// =============> write your prediction here
// =============> My prediction is code wont return anything because the function does not have a return statement.

function multiply(a, b) {
/* 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
console.log(`The result of multiplying 10 and 32 is `${multiply(10, 32)}`);
*/
// =============> Once return statement is added, it will return the result of the multiplication.

// Finally, correct the code to fix the problem
// =============> write your new code here
// =============>

function multiply(a,b)
{
return a*b;
}

console.log(`result of multiplying 2 times 2 = ${multiply(2, 2)}`);
15 changes: 11 additions & 4 deletions Sprint-2/2-mandatory-debug/1.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
// Predict and explain first...
// =============> write your prediction here
// =============> Problem here is that sum does not return no value because return statement and a + b is in different lines.

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

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

// =============> write your explanation here
*/
// =============> Once we put a + b back in return statement it will work with no problem.
// Finally, correct the code to fix the problem
// =============> write your new code here

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

console.log(`The sum of 45 and 12 is ${sum(45, 12)}`); // Output: "The sum of 45 and 12 is 57"
19 changes: 13 additions & 6 deletions Sprint-2/2-mandatory-debug/2.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Predict and explain first...

// Predict the output of the following code:
// =============> Write your prediction here
// =============> output would be undefined because getLastDigit uses global variable num.

const num = 103;
/* const num = 103;

function getLastDigit() {
return num.toString().slice(-1);
Expand All @@ -12,13 +12,20 @@ function getLastDigit() {
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)}`);

*/
// Now run the code and compare the output to your prediction
// =============> write the output here
// =============> Program is returning 3 for all console.log's.
// Explain why the output is the way it is
// =============> write your explanation here
// =============> Num is defined to 103 which is global so anytime program calls getLastDigit it returns 3.
// 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 41 is ${getLastDigit(41)}`);

// This program should tell the user the last digit of each number.
// Explain why getLastDigit is not working properly - correct the problem
9 changes: 7 additions & 2 deletions Sprint-2/3-mandatory-implement/1-bmi.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
// Then when we call this function with the weight and height
// It should return their Body Mass Index to 1 decimal place

const weight = 103;
const height = 1.87;

function calculateBMI(weight, height) {
// return the BMI of someone based off their weight and height
}
return calculatedBMI = (weight / (height * height)).toFixed(1);
}

console.log(`the BMI of the person is ${calculateBMI(weight, height)}`);
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 magicToUpperCase(input)
{
return input.toUpperCase().replaceAll(" ", "_");

}

console.log(magicToUpperCase("lord of the rings"));
25 changes: 25 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,28 @@
// 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


function toPounds(penceCount) {

const penceWithoutP = penceCount.substring(
0,
penceCount.length - 1
);

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

const pence = paddedPenceNumber
.substring(paddedPenceNumber.length - 2);


const formattedPounds = pounds || "0";

return `£${formattedPounds}.${pence}`;
}

console.log(`The amount in pounds is ${toPounds("10000000")}`);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this output?

Just be careful with formatting too - is there anything that could be improved?

Loading
Loading