generated from CodeYourFuture/Module-Template
-
-
Couldn't load subscription status.
- Fork 239
Manchester | 25-ITP-May | Mahtem T. Mengstu| Sprint 1 | Coursework/Sprint 1 #780
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
Open
Mahtem
wants to merge
16
commits into
CodeYourFuture:main
Choose a base branch
from
Mahtem:coursework/sprint-1
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 all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
d6c5c0b
Described what line 3 is doing
Mahtem 2ae5aaa
Declare a variable called initials that stores the first character of…
Mahtem ebd4d3e
Describe what line 3 is doing.
Mahtem 7eb19b3
Described what line three is doing.
Mahtem f683d85
Described what line three is doing.
Mahtem 76e6a40
Declared a variable named initials
Mahtem b9a5530
Created dir and ext variables
Mahtem fc1f2d4
Described what the prpgram is doing
Mahtem 927521c
Modified
Mahtem 7db8109
Modified
Mahtem 97637ad
Added codewar related code
Mahtem 5dab8a6
Used template string to display initials
Mahtem 6e76b0d
Differentiated const and let
Mahtem 6ac3015
Corrected typo
Mahtem 1e97c2e
Suggested better names in "camel case"
Mahtem 4010b4d
corrected name suggestion according to camelCase
Mahtem 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,6 +1,55 @@ | ||
| let count = 0; | ||
| //let count = 0; | ||
|
|
||
| count = count + 1; | ||
| //count = count + 1; | ||
|
|
||
| // Line 1 is a variable declaration, creating the count variable with an initial value of 0 | ||
| // Describe what line 3 is doing, in particular focus on what = is doing | ||
| // Line 3 returns the incremented value of count. The operator = assigns count +1 to the varibale count in the | ||
| // left. | ||
|
|
||
| // Described what line three is doing. | ||
|
|
||
| // Example from codewar (from programming workshop) | ||
|
|
||
| function drawStairs(n) { | ||
| let result = ""; | ||
| if (n < 1) return result; // nothing to do | ||
|
|
||
| let iCount = 0; | ||
| while (iCount < n) { | ||
| // add spaces before the I (for all lines after the first) | ||
| let spaceCount = 0; | ||
| while (spaceCount < iCount) { | ||
| result = result.concat(" "); | ||
| spaceCount = spaceCount + 1; | ||
| } | ||
|
|
||
| // add the "I" | ||
| result = result.concat("I"); | ||
|
|
||
| // add a newline after each line except the last one | ||
| if (iCount < n - 1) { | ||
| result = result.concat("\n"); | ||
| } | ||
|
|
||
| // update the count | ||
| iCount = iCount + 1; | ||
| } | ||
|
|
||
| return result; | ||
| } | ||
|
|
||
| console.log(drawStairs(10)); | ||
|
|
||
| /// Another example | ||
|
|
||
| function drawStairs(n) { | ||
| let result = []; | ||
|
|
||
| for (let i = 0; i < n; i++) { | ||
| result[i] = `${' '.repeat(i)}I`; | ||
| } | ||
|
|
||
| return result.join('\n'); | ||
| } | ||
| console.log(drawStairs(5)); |
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,2 +1,5 @@ | ||
| 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? | ||
|
|
||
| // We have solved it by adding two forward slashes (//) at the beginning of each line. | ||
| // The computer does not run this line too. |
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,14 @@ | ||
| // trying to create an age variable and then reassign the value by 1 | ||
|
|
||
| const age = 33; | ||
| //const age = 33; | ||
|
|
||
| // we need to replace "const" with "let", in javascript "const" is usd for variable | ||
| // that will nor change / will be kept constant troughout the code, where is "let" | ||
| // lets us to reassign variable later as we have done in the lines below the variabel age | ||
| // gets updated by one... | ||
|
|
||
| let age = 33; | ||
| age = 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,9 @@ | ||
| // 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}`); | ||
| // The variable cityOfBirth was called before it was defined, so we need to bring that variable first | ||
| const cityOfBirth = "Bolton"; | ||
| console.log(`I was born in ${cityOfBirth}`); | ||
|
|
||
| // Problem has been fixed | ||
|
|
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,20 @@ | ||
| const cardNumber = 4533787178994213; | ||
| const last4Digits = cardNumber.slice(-4); | ||
| //const last4Digits = cardNumber.slice(-4); | ||
|
|
||
| const last4Digits = cardNumber.toString().slice(-4); | ||
|
|
||
|
|
||
| console.log(last4Digits); | ||
|
|
||
| // The last4Digits variable should store the last 4 digits of cardNumber | ||
| // However, the code isn't working | ||
| // Before running the code, make and explain a prediction about why the code won't work | ||
| // Then run the code and see what error it gives. | ||
| // Consider: Why does it give this error? Is this what I predicted? If not, what's different? | ||
| // Then try updating the expression last4Digits is assigned to, in order to get the correct value | ||
|
|
||
| // I think the code does not work because cardNumber variable is not stored as string. | ||
|
|
||
| // My guess was right. | ||
|
|
||
| // Therefore first we need to change CardNumber variable into string before we use the slice method. |
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,14 @@ | ||
| const 12HourClockTime = "20:53"; | ||
| const 24hourClockTime = "08:53"; | ||
| const 24hourClockTime = "08:53"; | ||
|
|
||
| // Alternatively the above variable names can be corrected as follows: | ||
|
|
||
| // Option-1 | ||
|
|
||
| const twelveHourClockTime = "20:53"; | ||
| const twentyFourHourClockTime = "08:53"; | ||
|
|
||
| // Option -2 | ||
|
|
||
| const hour12ClockTime = "20:53"; | ||
| const hour24ClockTime = "08:53"; |
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,4 +1,4 @@ | ||
| const movieLength = 8784; // length of movie in seconds | ||
| const movieLength = -3500; // length of movie in seconds | ||
|
|
||
| const remainingSeconds = movieLength % 60; | ||
| const totalMinutes = (movieLength - remainingSeconds) / 60; | ||
|
|
@@ -13,13 +13,37 @@ console.log(result); | |
|
|
||
| // a) How many variable declarations are there in this program? | ||
|
|
||
| // Ans: There are 6 variable declaration: Line 1, Line 3, Line 4, Line 6, Line 7, Line 9, | ||
|
|
||
| // b) How many function calls are there? | ||
|
|
||
| // Ans: There is one function call ... log() | ||
|
|
||
| // c) Using documentation, explain what the expression movieLength % 60 represents | ||
| // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators | ||
|
|
||
| // Ans: The expression movieLength % 60 returns the remainder after totalMinutes is divided by 60. | ||
|
|
||
| // d) Interpret line 4, what does the expression assigned to totalMinutes mean? | ||
|
|
||
| // The expression is calculating how many full minutes are in the movie’s total length by removing leftover seconds(less than 60) | ||
|
|
||
| // e) What do you think the variable result represents? Can you think of a better name for this variable? | ||
|
|
||
| // Ans: the variable result represent total movie lenght, Movie duration_hr_min_sec would be better name. | ||
|
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. In Javascript, the convention is to use "camel case". This would be perfect for a language like Python 🙂 Could you suggest one in camel case? See this article: link |
||
|
|
||
| // In a "camel case" the following options would be better names | ||
| // 1. movieDurationHrMinSec | ||
| // 2. totalMovieSpan | ||
| // 3. totalMoviePeriod | ||
|
|
||
| // f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer | ||
|
|
||
| // Ans: I have tried with different values and it seems to work for all values, but it needs to validate to avoid entering negative values | ||
| // I inserted --3500 and returned 0: -58: -20 which does not mean real time representation. | ||
|
|
||
|
|
||
| // Corrected typo reminder -----> remainder | ||
| // Suggested better names in "camel case" a convention in Javascript | ||
|
|
||
| // corrected name suggestion according to camelCase | ||
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
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.
Thus,suggests to me this might've been generated by AIRemember, the aim of this is to ensure you're understanding the exercises. It's hard to do this if you don't write the answers in your own words
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.
We've decided
Thusis not a good indicator of AI 👀