-
-
Couldn't load subscription status.
- Fork 239
London | Sep-2025 | Gislaine Della Bella | Sprint 2 | coursework-sprint-2 #759
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 13 commits
83c273b
ced9817
a2d891a
812cf83
b9391ff
0440a7f
7fd4ee0
7d6b8da
bd99bf5
054d3ac
63a51e6
1802806
71f49ba
94d39b3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,25 @@ | ||
| // Predict and explain first... | ||
| // =============> write your prediction here | ||
| // =============> looking at it I think the sytntaks is worng return; a+b; | ||
|
|
||
| // function sum(a, b) { | ||
| // return; | ||
| // a + b; | ||
| // } | ||
|
|
||
| // console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); | ||
|
|
||
| // =============> | ||
| // I declare in the scope of function what a,b need to do return | ||
| // call the function with the template literal | ||
| // wich will give me the Text sentence with the result of any sum | ||
|
|
||
| // Finally, correct the code to fix the problem | ||
| // =============> | ||
|
|
||
| function sum(a, b) { | ||
| return; | ||
| a + b; | ||
| const newSum = a + b; | ||
| return newSum; | ||
|
|
||
| } | ||
|
|
||
| console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); | ||
|
|
||
| // =============> write your explanation here | ||
| // Finally, correct the code to fix the problem | ||
| // =============> write your new code here |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,24 +1,42 @@ | ||
| // Predict and explain first... | ||
|
|
||
| // Predict the output of the following code: | ||
| // =============> Write your prediction here | ||
| // =============> it is declaring num fisrt wich wil work but the function will stop after the | ||
| //calculate 103 results. after run Return if the results. | ||
|
|
||
| const num = 103; | ||
| // I din't predict rigt it gives the results all using the const Num= 103 | ||
|
|
||
| function getLastDigit() { | ||
| return num.toString().slice(-1); | ||
| } | ||
| // the consolo.log wont work | ||
|
|
||
| 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)}`); | ||
| // const num = 103; | ||
|
|
||
| // 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)}`); | ||
|
|
||
| // Now run the code and compare the output to your prediction | ||
| // =============> write the output here | ||
| // Explain why the output is the way it is | ||
| // =============> write your explanation here | ||
| // =============> it is using the const 103 for all the results | ||
|
|
||
| // Finally, correct the code to fix the problem | ||
| // =============> write your new code here | ||
|
|
||
| // This program should tell the user the last digit of each number. | ||
| // Explain why getLastDigit is not working properly - correct the problem | ||
|
|
||
|
|
||
| function getLastDigit(numtoCalculate) { //give a input to the function to use | ||
| const num = numtoCalculate.toString().slice(-1); //declare a const adding values to what to do | ||
| return num; // return the process | ||
| } | ||
|
|
||
| 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)}`); | ||
|
|
||
| //output | ||
| // The last digit of 42 is 2 | ||
| // The last digit of 105 is 5 | ||
| // The last digit of 806 is 6 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,3 +14,21 @@ | |
| // 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 | ||
|
|
||
|
|
||
| //1- methodo that take space add _ ? | ||
| //2- methodo find first index of ech word | ||
| //3- methodo to tranform string to upercase = toUpperCase() | ||
| //4- return the value | ||
|
|
||
|
|
||
|
|
||
| function takeSapcestoUpercase (textSnake){ | ||
|
|
||
| let takespace = textExemple.split(" ");// returns array nned to tranform to string again before upercase | ||
|
||
| let transfStringAgain = takespace.join("_"); | ||
| let changeUper = transfStringAgain.toUpperCase(1); | ||
| return changeUper; | ||
| }; | ||
| let textExemple = "hello there"; | ||
| console.log(takeSapcestoUpercase(textExemple)); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,43 @@ | ||
| // In Sprint-1, there is a program written in interpret/to-pounds.js | ||
|
|
||
| // You will need to take this code and turn it into a reusable block of code. | ||
|
|
||
| // need to get car price = let fullPrice | ||
| //need get priceOneyear= let priceOneyear | ||
| // need take the spaces off the both variables | ||
| //need check the diference of the prices | ||
| //multiplay the result for 100 to check the percentage | ||
| // return the result with template literals | ||
|
|
||
| //function needs to be valid with diferents inputs | ||
|
|
||
| // 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 | ||
|
|
||
|
|
||
| // let carPrice = "10,000"; | ||
| // let priceAfterOneYear = "8,543"; | ||
|
|
||
| // carPrice = Number(carPrice.replaceAll(",", ""));// 10000 | ||
| // priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",","")); //8543 | ||
|
|
||
| // const priceDifference = carPrice - priceAfterOneYear; //1457 | ||
| // const percentageChange = (priceDifference / carPrice) * 100; //145700 | ||
|
|
||
| // console.log(`The percentage change is ${percentageChange}`); //14.57 | ||
|
|
||
| function toPounds(fullPrice, priceOneyear) { | ||
|
|
||
| fullPrice = Number(fullPrice.replaceAll(",", "")); | ||
| priceOneyear = Number(priceOneyear.replaceAll(",", "")); | ||
|
|
||
| const priceDifference = fullPrice - priceOneyear; | ||
|
|
||
| const percentageChange = (priceDifference / fullPrice) * 100; | ||
|
|
||
| // console.log(`The percentage change is ${percentageChange}`); | ||
| return percentageChange; | ||
| } | ||
|
|
||
| console.log (toPounds( "100,000", "98,000")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you resolve this using a single line rather than 2 lines?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done 👍
function multiply(num1, num2) {
return num1 * num2;
}
console.log(
The result of multiplying 10 and 32 is ${multiply(10, 32)});