-
-
Notifications
You must be signed in to change notification settings - Fork 337
Manchester| ITP-Jan-26 | Ofonime Edak | Sprint 1| Structuring and Testing Data #1052
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
Changes from 2 commits
1c7d558
84027f2
63c55f5
ec16947
f76bcc1
789ad61
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,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? |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| // trying to create an age variable and then reassign the value by 1 | ||
|
|
||
| const age = 33; | ||
| let age = 33; | ||
| age = age + 1; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,8 @@ | ||
| // Currently trying to print the string "I was born in Bolton" but it isn't working... | ||
| // what's the error ? | ||
|
|
||
| console.log(`I was born in ${cityOfBirth}`); | ||
| // JavaScript is single-threaded because it executes tasks in a single flow using a call stack. The function was called before it was declared, | ||
| // It was also declared with const, which can not be hoisted to the top, like var. | ||
| // this result to undefined. | ||
|
|
||
| const cityOfBirth = "Bolton"; | ||
| console.log(`I was born in ${cityOfBirth}`); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| const 12HourClockTime = "20:53"; | ||
| const 24hourClockTime = "08:53"; | ||
| const twelveHourClockTime = "20:53"; | ||
| const twentyFourHourClockTime = "08:53"; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,14 +12,24 @@ console.log(result); | |
| // For the piece of code above, read the code and then answer the following questions | ||
|
|
||
| // a) How many variable declarations are there in this program? | ||
| // there are 6 variable declaration. | ||
|
|
||
| // b) How many function calls are there? | ||
| // One function call | ||
|
|
||
| // c) Using documentation, explain what the expression movieLength % 60 represents | ||
| // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators | ||
| // The % operator checks the remainder of that expression when being evaluated. It is similar to the remainder theorem in mathematics. | ||
| // if it returns 0, even, if it returns value other than zero, it odd. it is mostly used for checks in programming | ||
|
|
||
| // d) Interpret line 4, what does the expression assigned to totalMinutes mean? | ||
| // The total time for this movie is 8760 second and fractional 24 seconds, line 4 is used to deduct the fractional 24 seconds | ||
| // Then convert the whole number seconds to minute. | ||
|
|
||
| // e) What do you think the variable result represents? Can you think of a better name for this variable? | ||
| // the variable result represent total movie duration in hours,minute and seconds. | ||
| // const=movieDuration | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The name One more try for a more descriptive name? |
||
|
|
||
| // f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer | ||
| // this code works for all movie length and integer values. | ||
| // for movie length which are multiples of 60 it returns hours with 0 minutes and 0 seconds | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,14 +6,9 @@ const penceStringWithoutTrailingP = penceString.substring( | |
| ); | ||
|
|
||
| const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"); | ||
| const pounds = paddedPenceNumberString.substring( | ||
| 0, | ||
| paddedPenceNumberString.length - 2 | ||
| ); | ||
| const pounds = paddedPenceNumberString.substring(0,paddedPenceNumberString.length - 2); | ||
|
|
||
| const pence = paddedPenceNumberString | ||
| .substring(paddedPenceNumberString.length - 2) | ||
| .padEnd(2, "0"); | ||
| const pence = paddedPenceNumberString .substring(paddedPenceNumberString.length - 2).padEnd(2, "0"); | ||
|
|
||
| console.log(`£${pounds}.${pence}`); | ||
|
|
||
|
|
@@ -25,3 +20,12 @@ console.log(`£${pounds}.${pence}`); | |
|
|
||
| // To begin, we can start with | ||
| // 1. const penceString = "399p": initialises a string variable with the value "399p" | ||
| // 2. const penceStringWithoutTrailingP = penceString.substring(0,penceString.length - 1);: used to strip off the last substring character 'p' | ||
| // 3. const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"): Used to add '0' to the start of the string if the string | ||
| // length is less than 3, else if string length is 3 it does not pad. | ||
| // 4.const pounds = paddedPenceNumberString.substring(0,paddedPenceNumberString.length - 2);: This expression copy the first character | ||
| // from every length character of the padded string | ||
| // 5.const pence = paddedPenceNumberString .substring(paddedPenceNumberString.length - 2).padEnd(2, "0");: This expression add '0' to the end if the paddedString is not | ||
| // upto 2 characters | ||
|
Comment on lines
+33
to
+34
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Optional challenge:
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't really need the .padEnd() at the end, as it helps only when the length of the string is less than 3
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How do you know if |
||
| // 6. this line is a function call to log the argument inside it to the console. it use template literals to get the values of the variables | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,9 +10,17 @@ Let's try an example. | |
| In the Chrome console, | ||
| invoke the function `alert` with an input string of `"Hello world!"`; | ||
|
|
||
| It invokes the modal window and display Hello world | ||
|
|
||
| What effect does calling the `alert` function have? | ||
| It freezes the window till i click Ok before ii can make use of my computer | ||
|
|
||
| Now try invoking the function `prompt` with a string input of `"What is your name?"` - store the return value of your call to `prompt` in an variable called `myName`. | ||
| const myName=prompt(`"What is your name?"`) | ||
| return value myName=Edak | ||
|
|
||
| What effect does calling the `prompt` function have? | ||
| it invokes a modal window, and allows me to enter an input value | ||
| What is the return value of `prompt`? | ||
| it returns the value i entered "Edak" | ||
|
Comment on lines
23
to
+24
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What would the function return if you entered "Edak" and clicked "Cancel" instead of "OK"? |
||
| It will return null. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,12 +5,21 @@ In this activity, we'll explore some additional concepts that you'll encounter i | |
| Open the Chrome devtools Console, type in `console.log` and then hit enter | ||
|
|
||
| What output do you get? | ||
| I get `f log(){[native code]}` in return | ||
|
|
||
| Now enter just `console` in the Console, what output do you get back? | ||
| I get`console{debug: f,error:f,info:f,log:f....}` | ||
|
|
||
| Try also entering `typeof console` | ||
|
|
||
| I get `object` | ||
| Answer the following questions: | ||
|
|
||
| What does `console` store? | ||
| The console store methods for debugging the console such as assert. clear,count,countReset,debug etc | ||
|
|
||
| What does the syntax `console.log` or `console.assert` mean? In particular, what does the `.` mean? | ||
|
|
||
| console.log: Output a message to the console | ||
|
|
||
| console.assert: Log an error message to the console if the first argument is false. | ||
| `.` the console stored methods. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file is not related to Sprint-1 exercise. If you don't revert (undo) the change, the validation bot will keep complaining and prevent you from using the "Needs Review" label. One way to revert changes to a file is via the First, locate a commit before the file was modified. It could be the first commit you made, assuming the branch started in a clean state. Next, record the first 7 characters of the commit SHA. Suppose the file is After the file is restored, make a commit and push the changes to GitHub. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,16 @@ | ||
| function countChar(stringOfCharacters, findCharacter) { | ||
| return 5 | ||
| let count=0; | ||
| for(let i=0; i<stringOfCharacters.length; i++){ | ||
|
|
||
| if(stringOfCharacters[i]===findCharacter){ | ||
| count++; | ||
| }else{ | ||
| return 0 | ||
| } | ||
|
|
||
| } | ||
| return count; | ||
| } | ||
|
|
||
|
|
||
| module.exports = countChar; |
Uh oh!
There was an error while loading. Please reload this page.