Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d4f54bb

Browse files
committed
feat: Add array exercise 15
1 parent 818a0af commit d4f54bb

File tree

2 files changed

+44
-16
lines changed

2 files changed

+44
-16
lines changed

‎README.md‎

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -419,8 +419,8 @@ Create a new array called `tempF`. Each element in the new array should be the c
419419
Output should look like this:
420420

421421
```javascript
422-
Temperature in Celsisus: 0,10,20,30,-5,15
423-
Temperature in Fahrenheit: 32,50,68,86,23,59
422+
console.log(tempC); // expected: 0,10,20,30,-5,15
423+
console.log(tempF); // expected: 32,50,68,86,23,59
424424
```
425425

426426
✔️ [Solution: tempConversion.js](./array-exercises/10_tempConversion.js)
@@ -437,9 +437,9 @@ Create another new array `startWithA` that contains only the words that start wi
437437
Log all three arrays to the console. Output should look like this:
438438

439439
```javascript
440-
'Original array: augmentation,desk,building,bed,affiliate,ant,sunshine,Ann'
441-
'Only long words (>6 characters): augmentation,building,affiliate,sunshine'
442-
'Words with an A: augmentation,affiliate,ant,Ann'
440+
console.log(words); //augmentation,desk,building,bed,affiliate,ant,sunshine,Ann
441+
console.log(longWords); // augmentation,building,affiliate,sunshine
442+
console.log(startWithA); // augmentation,affiliate,ant,Ann
443443
```
444444

445445
✔️ [Solution: filterWords.js](./array-exercises/11_filterWords.js)
@@ -456,16 +456,16 @@ Calculate the product of all numbers in the array amd store it in a variable `to
456456
Output should look like this:
457457

458458
```javascript
459-
Array of numbers: 1,2,3,4,5
460-
Total sum: 15, total product: 120
459+
console.log('Array of numbers: ',numbers);//Array of numbers: 1,2,3,4,5
460+
console.log('Total sum: ',totalSum, 'total product: ',totalProduct);// Total sum: 15, total product: 120
461461
```
462462

463463
✔️ [Solution: sumAndProduct.js](./array-exercises/12_sumAndProduct.js)
464464
</details>
465465

466466

467467
<details>
468-
<summary><strong>🟡 Exercise 13: Sum & Product </strong></summary>
468+
<summary><strong>🟡 Exercise 13: Test Results </strong></summary>
469469

470470
Create an array `testResults` containing numbers ([85, 92, 78, 65, 95, 70, 88]) representing test results.
471471

@@ -476,11 +476,12 @@ Create an array `testResults` containing numbers ([85, 92, 78, 65, 95, 70, 88])
476476
Output should look like this:
477477

478478
```javascript
479-
Array with test results: 85,92,78,65,95,70,88
480-
First excellent result (>90) is: 92
481-
First result below 70 is on position: 3
482-
Are there any failing results? (<60): false
483-
Is every result bigger than 50?: true
479+
console.log(`Array with test results: ${testResults}`); //expected: 85,92,78,65,95,70,88
480+
console.log(`First excellent result (>90) is: ${firstExcellent}`); // 92
481+
console.log(`First failing (<70) is on position: ${indexFirstFailing}`); // 3
482+
console.log(`Are there any failing results? (<60): ${hasFailing}`); // false
483+
console.log(`Is every result bigger than 50?: ${areBigger}`); // true
484+
484485
```
485486

486487
✔️ [Solution: testResults.js](./array-exercises/13_testResults.js)
@@ -495,14 +496,33 @@ Create a new array `discountedPrices` containing only prices that are greater th
495496

496497

497498
```javascript
498-
Product prices: 15.99,23.5,5,12.75,30.2,8.99
499-
All discounted prices: 14.391,21.15,11.475,27.18
500-
Discounted prices - total: 74.196
499+
console.log(productPrices); // 15.99,23.5,5,12.75,30.2,8.99
500+
console.log(discountedPrices); // 14.391,21.15,11.475,27.18
501+
console.log(total); // 74.196
501502
```
502503

503504
✔️ [Solution: discounted.js](./array-exercises/14_discounted.js)
504505
</details>
505506

507+
<details>
508+
<summary><strong>🟠 Exercise 15: Formatting City Names </strong></summary>
509+
510+
Create an array `cityNames`= ["lisBOa", "marbella","vallettA", "Split", "theSSaloniKI", "napoLi", "sALERNO"].
511+
512+
Create a new array named `formattedCities` where each city name will have its first letter capitalized and the rest in lowercase. [Example: "lisBOa" -> "Lisboa"]
513+
514+
Create a new array `citiesWithS` that contains only the cities (from the original array) whose name starts with the letter 'S' (case-insensitive). Output should look like this:
515+
516+
```javascript
517+
console.log(cityNames); // lisBOa,marbella,vallettA,Split,theSSaloniKI,napoLi,sALERNO
518+
console.log(formattedCities); // Lisboa,Marbella,Valletta,Split,Thessaloniki,Napoli,Salerno
519+
console.log(citiesWithS); // Split,sALERNO
520+
```
521+
522+
✔️ [Solution: formattingCities.js](./array-exercises/15_formattingCities.js)
523+
</details>
524+
525+
506526
---
507527

508528
## Resources 📚
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
const cityNames=["lisBOa", "marbella","vallettA", "Split", "theSSaloniKI", "napoLi", "sALERNO"];
3+
const formattedCities = cityNames.map ((city) => city[0].toUpperCase()+city.slice(1,).toLowerCase());
4+
const citiesWithS = cityNames.filter ((city)=> (city[0]==="s") || (city[0]==="S"));
5+
6+
console.log(`Original array: ${cityNames}
7+
Formatted array: ${formattedCities}
8+
Cities that start with 's'/'s' (unformatted): ${citiesWithS}`);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /