Skip to content
Open
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
c6a44f1
first prediction
gaireprakash20-ops Sep 27, 2026
161d044
o.js has been fixed and output is Ramesh
gaireprakash20-ops Sep 27, 2026
e09336a
predict to write return in line 6
gaireprakash20-ops Sep 27, 2026
ffcaf92
Put return instead of console.log
gaireprakash20-ops Sep 27, 2026
370f927
change and finally got the error fixed
gaireprakash20-ops Sep 27, 2026
450b81e
Predict and put the num inside the get last digit function
gaireprakash20-ops Sep 27, 2026
2cb2539
Delete and cons and put convertToPercentage function back in the code
gaireprakash20-ops Sep 27, 2026
36a8256
change the function assigning the variable num .
gaireprakash20-ops Sep 27, 2026
ccccc5a
In this , i make the height squared and then divide the weight by the…
gaireprakash20-ops Sep 27, 2026
7c0c3df
Lower case is changed into upper case and spaces are replaced with un…
gaireprakash20-ops Sep 27, 2026
cac70ad
make a function to convert pence to pounds
gaireprakash20-ops Sep 27, 2026
9dcb6ac
give a answer to the question in the file 4-mandatory-interpret/time-…
gaireprakash20-ops Sep 27, 2026
9e097c2
update the height of the person 1.73 and update the comment 24
gaireprakash20-ops Sep 29, 2026
dff88a2
make atype error into syntex errorans soon.
gaireprakash20-ops Sep 29, 2026
87ff7d9
replace function name touppercase with toUpperSnakeCase
gaireprakash20-ops Sep 29, 2026
6cdfd03
i changed the function name topounds from topound and also changed t…
gaireprakash20-ops Sep 29, 2026
992bd50
i comment the line 29 not removed.
gaireprakash20-ops Sep 29, 2026
3a7d287
Removed the line 29
gaireprakash20-ops Sep 30, 2026
c1bba88
last commit by take out of
gaireprakash20-ops Sep 30, 2026
0a4d5aa
i changed the single quotes to double quotes in the toUpperSnakeCase …
gaireprakash20-ops Oct 1, 2026
c4e8a63
i formate the file
gaireprakash20-ops Oct 1, 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
22 changes: 17 additions & 5 deletions Sprint-3/1-key-errors/0.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
// Predict and explain first...
// =============> write your prediction here
// =============> write your prediction here :there is a syntax error because string is decleared two tiimes.

// call the function capitalise with a string input
// interpret the error message and figure out why an error is occurring
//while calling a function capitalise occured a error. The error is occured due to declared of Str two times.

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

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

// =============> write your explanation here
// to resolve this error we need to declared a new variable in step 9. after declaring a new variable it runs and give outputs.
//which first letter is capital and other are remain same.
// =============> write your new code here
function capitalise(str) {
let ab = `${str[0].toUpperCase()}${str.slice(1)}`;
return ab;
}
capitalise("ramesh");
// The correct code is given above i pass a value ramesh after running this function the output become Ramesh.

26 changes: 18 additions & 8 deletions Sprint-3/1-key-errors/1.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
// Predict and explain first...

// Why will an error occur when this program runs?
// =============> write your prediction here
// =============> I think when we run the programme it will show the type error because decimal number is reassigning inside the function.

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

function convertToPercentage(decimalNumber) {
const decimalNumber = 0.5;
const percentage = `${decimalNumber * 100}%`;
// function convertToPercentage(decimalNumber) {
// const decimalNumber = 0.5;
// const percentage = `${decimalNumber * 100}%`;

return percentage;
}
// return percentage;
// }

console.log(decimalNumber);
// console.log(decimalNumber);

// =============> write your explanation here

// while running this function is shows SyntaxError because decimal number variable is declared two times which JavaScript does not allow.
// and in step 15 we need call function name not decimal number.
// Finally, correct the code to fix the problem
// =============> write your new code here
function convertToPercentage(decimalNumber) {

const percentage = `${decimalNumber * 100}%`;

return percentage;
}

console.log(convertToPercentage(0.5));
// After solving this the output is 50%.
16 changes: 13 additions & 3 deletions Sprint-3/1-key-errors/2.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@

// Predict and explain first BEFORE you run any code...
// It show the reference error cause function not assigned the variable so that, code is stuck.

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

// =============> write your prediction of the error here

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

// =============> write the error message here
// the message is SyntaxError: Unexpected number.

// =============> explain this error message here
// The error message is occured due to not assigning the variable in function. TO solve this problems we need to assign the num variable in function.

// Finally, correct the code to fix the problem

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

console.log(square(3));
// The output of this programme is 9.



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

// =============> write your prediction here
// =============> write your prediction here : In step six we need to write return type and output become 320.

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

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

// =============> write your explanation here
// =============> write your explanation
// There should be return but code is perfectly run without changing the return type instead of console.log in line 6.

// Finally, correct the code to fix the problem
// Finally, correct the code to fix the problem
// In the section there has no output error but console is for getting output in print but in function there should be a return type so that after correcting this code
// the output become The result of multiplying 10 and 32 is 320.
// =============> write your new code here
function multiply(a, b) {
return a * b;
}

console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);
19 changes: 13 additions & 6 deletions Sprint-3/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
// As per this question the answer is not defined but answer should be 42.
// function sum(a, b) {
// return;
// a + b;
// }

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

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

// =============> write your explanation here
//In this question return type has no value so we need to put a+b in step 5. The step 5 will be return a+b;.
// 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 10 and 32 is ${sum(10, 32)}`);
// After correcting this code we get the exact output 42. Without correction the output is The sum of 10 and 32 is undefined.
34 changes: 26 additions & 8 deletions Sprint-3/2-mandatory-debug/2.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,42 @@
// Predict and explain first...
// Predict and explain first
// As per the code output should be the last digits of the given number .

// Predict the output of the following code:
// =============> Write your prediction here
//
// The output always be 3 3 3 3 3 3 3 but i thought output should be the last digits.

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

function getLastDigit() {
return num.toString().slice(-1);
}
// function getLastDigit() {
// 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)}`);
// 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
// The last digit of 42 is 3
// The last digit of 105 is 3
// The last digit of 806 is 3
// Explain why the output is the way it is
// =============> write your explanation here
// In this variable num is constant and there is no any declaration in function name. Due to this reasons result always be 3.
// Finally, correct the code to fix the problem
// =============> write your new code here
// const num = 103;

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
// To solve this problems we need to write variable in function.
5 changes: 5 additions & 0 deletions Sprint-3/3-mandatory-implement/1-bmi.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,9 @@

function calculateBMI(weight, height) {
// return the BMI of someone based off their weight and height
let squared_height = height * height;
const bmi = weight/squared_height;
return bmi.toFixed(1);
}
console.log(`The BMi of the person is ${calculateBMI(70,1.73)}`);
// The output of the program is 'The BMi of the person is 23.4'.
5 changes: 5 additions & 0 deletions Sprint-3/3-mandatory-implement/2-cases.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,8 @@
// 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 toUpperSnakeCase(str){
return str.replaceAll(' ', '_').toUpperCase();
}
console.log(toUpperSnakeCase('hello there'));
// The output of the given code is HELLO_THERE
17 changes: 17 additions & 0 deletions Sprint-3/3-mandatory-implement/3-to-pounds.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,20 @@
// 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(penceString) {
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");
return `£${pounds}.${pence}`;
}
console.log(toPounds("399p"));
console.log(toPounds("2p"));
10 changes: 9 additions & 1 deletion Sprint-3/4-mandatory-interpret/time-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ function formatTimeDisplay(seconds) {

return `${pad(totalHours)}:${pad(remainingMinutes)}:${pad(remainingSeconds)}`;
}
console.log(formatTimeDisplay(61))

// You will need to play computer with this example - use the Python Visualiser https://pythontutor.com/visualize.html#mode=edit
// to help you answer these questions
Expand All @@ -22,17 +23,24 @@ function formatTimeDisplay(seconds) {

// a) When formatTimeDisplay is called how many times will pad be called?
// =============> write your answer here
// The pad is called 3 times in step 15.

// 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 which is assigned to num when pad is called for the first time is 0.
// c) What is the return value of pad when it is called for the first time?
// =============> write your answer here
// The value of pad when it is called for the first time "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 assign to num is 1.
// because the last call to pad is pad(remainingSeconds), and remainingSeconds is 1
// when formatTimeDisplay(61) is called.

// 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 return value is "01" because the last call to pad is pad(1).
// The pad function add a zero to make the number two digits.
Loading