This repository was archived by the owner on Jan 14, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 279
LONDON CLASS 8 - BERKELI HALMYRADOV - JS CORE 1 - WEEK 3 #2
Open
berkeli
wants to merge
5
commits into
CodeYourFuture:main
Choose a base branch
from
berkeli:berkeli-halmyradov
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
5 commits
Select commit
Hold shift + click to select a range
e7f5d82
Exercises and mandatory tasks complete
berkeli 26e03dc
extra challenges completed
berkeli 1824a94
Installed eslint anf formatted files
berkeli 2704413
Fixed typo issues, undeclared vars
berkeli d1563d6
Updated exercise 2 as it should log instead of return
berkeli 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 |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| module.exports = { | ||
| env: { | ||
| browser: true, | ||
| es2021: true, | ||
| node: true, | ||
| 'jest/globals': true, | ||
| }, | ||
| extends: [ | ||
| 'airbnb-base', | ||
| 'plugin:jest/recommended', | ||
| ], | ||
| parserOptions: { | ||
| ecmaVersion: 13, | ||
| sourceType: 'module', | ||
| }, | ||
| rules: { | ||
| quotes: ['error', 'single', { avoidEscape: true }], | ||
| 'max-len': 0, | ||
| 'no-console': 'off', | ||
| 'no-plusplus': 'off', | ||
| }, | ||
| plugins: ['jest'], | ||
| }; |
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,15 +1,24 @@ | ||
| /* eslint-disable no-multi-assign */ | ||
| /* | ||
| Sometimes when using loops, we'll want to execute the body of the loop at least once. We can make sure this happens by using a do-while loop. | ||
| - If the condition in a while loop is initially false, the body of the loop will never execute | ||
| - But in a do-while loop, because the condition is checked after the body, we know that it will always execute at least once | ||
|
|
||
| Using a do-while loop, write a function which returns the sum of the first n even numbers (starting from 0) | ||
| */ | ||
|
|
||
| function evenNumbersSum(n) { | ||
| // TODO | ||
| } | ||
| const evenNumbersSum = (n) => { | ||
| let evenNumber = 0; | ||
| let count = 0; | ||
| let sumEvenNumbers = 0; | ||
|
berkeli marked this conversation as resolved.
|
||
| do { | ||
| sumEvenNumbers += evenNumber; | ||
| evenNumber += 2; | ||
| count++; | ||
| } while (count < n); | ||
| return sumEvenNumbers; | ||
| }; | ||
|
|
||
| console.log(evenNumbersSum(3)); // should output 6 | ||
| console.log(evenNumbersSum(0)); // should output 0 | ||
| console.log(evenNumbersSum(10)); // should output 90 | ||
| console.log(evenNumbersSum(10)); // should output 90 | ||
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,16 +1,24 @@ | ||
| /* eslint-disable no-restricted-syntax */ | ||
| /* | ||
| A for-of loop is a easy and way of looping through the elements of an array, string or any other "iterable object" (think sequence of elements). | ||
| A for-of loop is a easy and way of looping through the elements of an array, string or any other "iterable object" (think sequence of elements). | ||
| */ | ||
|
|
||
| // TODO Use a for-of loop to output each of the tube stations below. | ||
| let tubeStations = [ | ||
| "Aldgate", | ||
| "Baker Street", | ||
| "Picadilly Circus", | ||
| "Oxford Street", | ||
| "Tottenham Court Road" | ||
| const tubeStations = [ | ||
| 'Aldgate', | ||
| 'Baker Street', | ||
| 'Picadilly Circus', | ||
| 'Oxford Street', | ||
| 'Tottenham Court Road', | ||
| ]; | ||
|
|
||
| for (const station of tubeStations) { | ||
| console.log(station); | ||
| } | ||
|
|
||
| // TODO Use a for-of loop to capitalise and output each letter in the string seperately. | ||
| let str = "codeyourfuture"; | ||
| const str = 'codeyourfuture'; | ||
|
|
||
| for (const letter of str) { | ||
| console.log(letter.toUpperCase()); | ||
| } |
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
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.
Uh oh!
There was an error while loading. Please reload this page.