This repository was archived by the owner on Apr 18, 2025. It is now read-only.
generated from CodeYourFuture/Module-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 50
NW6|Bakhat Begum| Module.JS-1| Bakhat/week 4|Sprint-4|Week-4 #178
Open
BakhatBegum
wants to merge
55
commits into
CodeYourFuture:main
Choose a base branch
from
BakhatBegum:bakhat/week-4
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 44 commits
Commits
Show all changes
55 commits
Select commit
Hold shift + click to select a range
6813bfc
added command and variables
49d40f7
added variable, working with Math.floor, Math.roound,Math.random and …
c85d42b
working on file
dda5f90
working on a file path
0c65f52
for update
BakhatBegum ba7225d
working on BMI
BakhatBegum 88cc3c6
working with toUppercase and white space
BakhatBegum 7af8cc5
Prediction and explanation with output results
BakhatBegum e4f4ad5
have worked on argument and function parameter.
BakhatBegum fdee53e
I have worked on function, variable, Math.floor, Math.round and toFixed
BakhatBegum f52f53f
calling funtion
BakhatBegum ae50334
update code
BakhatBegum addc187
next solution
BakhatBegum 2591330
multiplying price
BakhatBegum 0e678b1
working on assertion
BakhatBegum 5e757d5
working on angle
BakhatBegum 646bb10
added condition
BakhatBegum c985e13
working on fraction
BakhatBegum 569154a
function to return triangle
BakhatBegum 9b7c15a
fraction output
BakhatBegum 5d5b75a
condition for fraction
BakhatBegum 3e5f474
store expression in new variable.
BakhatBegum df15012
working on Unicode character
BakhatBegum ba3a263
understanding code and try to figure out my error.
BakhatBegum 4b5f604
changed return value
BakhatBegum 569c6fd
debug errors
BakhatBegum 71954f9
some codes were deleted my mistakes
BakhatBegum f115c6f
added some lines of code
BakhatBegum 984afdf
Because of software I lost my codes and rewrite code again.
BakhatBegum 9814ace
added variable
BakhatBegum a713454
added test.json file.
BakhatBegum 8c6dc69
working on count file.
BakhatBegum 0d9a980
added test case on count.js
BakhatBegum 8ec4c33
created function for validator file.
BakhatBegum ad14052
working of if condition.
BakhatBegum 7c64157
working on case test.
BakhatBegum c254fad
added code on function body.
BakhatBegum e3a5e12
added test case on is-prime.test.js file
BakhatBegum fc8fe13
where was an error on code.
BakhatBegum 45badd5
added for loop
BakhatBegum 438db85
added answer to given questions.
BakhatBegum 53fb6de
added index in loop.
BakhatBegum 067e144
added code on how to return 0 if there is any capital letter in string.
BakhatBegum 91083b5
added code
BakhatBegum f851252
addded changes
BakhatBegum d67c88f
changed var to let
BakhatBegum 4c6d858
To find the frequency of a string, I have used a forEach loop.
BakhatBegum ebc1869
The variable has been updated from 'var' to 'let'.
BakhatBegum ca44437
The test case order has been changed.
BakhatBegum f32d7ad
changed variable name sq to squareRoot
BakhatBegum 9dd4e73
added more test case
BakhatBegum fe1341b
there was a mistake on if statement
BakhatBegum 7289ea9
added test case
BakhatBegum e407d93
I have rewritten the code using a loop.
BakhatBegum 2a1cca5
Update 3.js
BakhatBegum File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| This is just an instruction for the first activity - but it is just for human consumption | ||
| We don't want the computer to run these 2 lines - how can we solve this problem? | ||
| //This is just an instruction for the first activity - but it is just for human consumption | ||
| //We don't want the computer to run these 2 lines - how can we solve this problem ? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| // trying to create an age variable and then reassign the value by 1 | ||
|
|
||
| const age = 33; | ||
| age = age + 1; | ||
| let age = 33; | ||
| age += 1; | ||
| console.log(age); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| // Currently trying to print the string "I was born in Bolton" but it isn't working... | ||
| // what's the error ? | ||
| //ans : In JavaScrip/node.js the code executed from top to bottom, any variable must be declare before log it to console. | ||
|
|
||
| console.log(`I was born in ${cityOfBirth}`); | ||
| const cityOfBirth = "Bolton"; | ||
| console.log(`I was born in ${cityOfBirth}`); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,10 @@ | ||
| const cardNumber = 4533787178994213; | ||
| const last4Digits = cardNumber.slice(-4); | ||
| const cardNumberAsString = cardNumber.toString() | ||
| const last4Digits = cardNumberAsString.slice(-4); | ||
|
|
||
| console.log(last4Digits); | ||
| // The last4Digits variable should store the last 4 digits of cardNumber | ||
| // However, the code isn't working | ||
| // Make and explain a prediction about why the code won't work | ||
| //ans: I think we use .slice method for string. According to me, .toFixed() method will work on card. The method .toFixed() is used for numerical values . | ||
| // Then try updating the expression last4Digits is assigned to, in order to get the correct value | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,5 @@ | ||
| const 12HourClockTime = "20:53"; | ||
| const 24hourClockTime = "08:53"; | ||
| const twelveHourClockTime = "20:53"; | ||
| const twentyOneHourClockTime = "08:53"; | ||
| console.log(twelveHourClockTime); | ||
| console.log(twentyOneHourClockTime); | ||
| // we can not initialize variable with numbers or with first capital letter. JavaScript is a case sensitive language. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,15 @@ | ||
| let firstName = "Creola"; | ||
| let middleName = "Katherine"; | ||
| let lastName = "Johnson"; | ||
| let firstName = "creole"; | ||
| let middleName = "katherine"; | ||
| let lastName = "johnson"; | ||
|
|
||
| let initials = firstName.charAt(0).toUpperCase() + firstName.slice(1); | ||
| let initialsTwo = middleName.charAt(0).toUpperCase() + middleName.slice(1); | ||
| let initialsThree = lastName.charAt(0).toUpperCase() + lastName.slice(1); | ||
|
|
||
|
|
||
| console.log(initials); | ||
| console.log(initialsTwo); | ||
| console.log(initialsThree); | ||
|
|
||
| // Declare a variable called initials that stores the first character of each string in upper case to form the user's initials | ||
| // Log the variable in each case |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,33 @@ | ||
| // Predict and explain first... | ||
| //Ans: The code defines a function called sum that takes two parameters a and b. | ||
|
|
||
| //Inside the function, it simply prints out the result of adding a and b using return a * b. | ||
|
|
||
| // After defining the function, the code calls the sum function, passing 10 and 32 as the arguments. | ||
|
|
||
| // The results of the function call are inserted into a template literal `The result of adding 10 and 32 is ${multiply(10, 32)}` | ||
|
|
||
| // So when this line runs, it will call the sum function, adding 10 and 32. | ||
|
|
||
| // The sum function will not print out 42. So when you call sum(10, 32), the function executes return; which | ||
|
|
||
| // exits the function immediately without returning any value. | ||
|
|
||
| // Hence, since the function doesn't return anything explicitly, the returned value is undefined. | ||
|
|
||
| // Here is a correct code. | ||
| //function sum(a, b) { | ||
| // return a + b; | ||
| // } | ||
|
|
||
| function sum(a, b) { | ||
| return; | ||
| a + b; | ||
| a + b; | ||
| } | ||
|
|
||
|
|
||
| // Here is a correct code. | ||
| function sum(a, b) { | ||
| return a + b; | ||
| } | ||
| console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,29 @@ | ||
| // Predict and explain first... | ||
| // Ans: the code define num variable with value 0f 103. We have function called getLastDigit. | ||
| //Inside the function, it simply prints out the result of last digit using return num.toString().slice(-1). | ||
| //After defining the function, the code calls the getLastDigit() function, passing 42, 105 and 806 as the arguments. | ||
| //The results of the function call are inserted into a template literal | ||
| //`The last digit of 42 is ${getLastDigit(42)}`); output: 3 | ||
| //`The last digit of 105 is ${getLastDigit(105)}`); output: 3 | ||
| //`The last digit of 806 is ${getLastDigit(806)}`); output: 3 | ||
|
|
||
| const num = 103; | ||
|
|
||
| function getLastDigit() { | ||
| const numOne = 42; | ||
| const numTwo = 105; | ||
| const numThree = 806; | ||
|
|
||
| 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)}`); | ||
| console.log(`The last digit of 42 is ${getLastDigit(numOne, 42)}`); | ||
| console.log(`The last digit of 105 is ${getLastDigit(numTwo, 105)}`); | ||
| console.log(`The last digit of 806 is ${getLastDigit(numThree, 806)}`); | ||
|
|
||
| // This program should tell the user the last digit of each number. | ||
| // Explain why getLastDigit is not working properly - correct the problem | ||
| //Ans: The key issue is that getLastDigit() function doesn't accept any parameters. It always just returns the last digit of the num variable defined outside the function. | ||
| // So when you call getLastDigit(42), the 42 is ignored. | ||
| // Inside getLastDigit(), it converts the num variable (which is 103) to a string, takes the last character (3) and returns that. | ||
| // It has no way to access the 42 value passed to it. | ||
| // To fix it, you need to update the function to accept a parameter. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,27 @@ | ||
| // Predict and explain first... | ||
| //Ans: You're absolutely right! Calling the capitalize function as shown would result in a SyntaxError. | ||
| //The key reason is that the capitalize function has not been defined anywhere before calling it. | ||
| //In JavaScript, you have to first declare/define a function before you can call it. | ||
|
|
||
| // write down the error you predict will be raised | ||
| // then call the function capitalise with a string input | ||
| //ans ; syntaxError. | ||
| // then call the function capitalize with a string input | ||
| // interpret the error message and figure out why it's happening, if your prediction was wrong | ||
| //ans; My prediction was right about syntaxError.. | ||
|
|
||
| function capitalize(text) { | ||
| let str = `${text[0].toUpperCase()}${text.slice(1)}`; | ||
| return str; | ||
| } | ||
| let text = "i like ice-cream"; | ||
| console.log(capitalize(text)); | ||
|
|
||
|
|
||
|
|
||
| function capitalise(str) { | ||
| let str = `${str[0].toUpperCase()}${str.slice(1)}`; | ||
| //here is the correct | ||
| function capitalize(text) { | ||
| let str = `${text[0].toUpperCase()}${text.slice(1)}`; | ||
| return str; | ||
| } | ||
| let text1 = "i like ice-cream"; | ||
| console.log(capitalize(text)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,20 @@ | ||
| // Predict and explain first... | ||
|
|
||
| //ans ; we declared const decimalNumber inside the body function it mean it is Local scope, which never allow variable to call out side the function. | ||
| // as a result we face syntexError. | ||
| // Write down the error you predict will be raised | ||
| //ans; syntaxError | ||
| // Why will an error occur when this program runs? | ||
| //ans: Variable Scope: If the variable is defined within the function using the var, let, or const keyword, it is only accessible within that function's scope. | ||
| // Play computer with the example to work out what is going on | ||
|
|
||
| function convertToPercentage(decimalNumber) { | ||
| const decimalNumber = 0.5; | ||
| const percentage = `${decimalNumber * 100}%`; | ||
|
|
||
| return percentage; | ||
| } | ||
| console.log(convertToPercentage(0.5)); | ||
|
|
||
| console.log(decimalNumber); | ||
| // here is the second solution | ||
| // const decimalNumber = 0.5; | ||
| // console.log(convertToPercentage(decimalNumber)); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Your solution is correct. For clarification, the
toFixed()method you mentioned is used to format numbers with a specific number of decimal places. You can check the mdn https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed