Created
August 26, 2024 20:53
-
-
Save Jifar71/4a93031f6b93b60acaf99d0b4eed79fc to your computer and use it in GitHub Desktop.
this code work on the price value of some array and change some of it's value inside the arrays
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
| /* | |
| * Programming Quiz: The Price is Right | |
| */ | |
| /* | |
| * QUIZ REQUIREMENTS | |
| * - Your code should have a variable `prices` | |
| * - The value of the 1st, 3rd, and 7th elements should be doubled | |
| * - Your code should print `prices` to the console as an array. Do not iterate over the elements. | |
| */ | |
| const prices = [1.23, 48.11, 90.11, 8.50, 9.99, 1.00, 1.10, 67.00]; | |
| // your code goes here | |
| for (let index = 0; index < prices.length; index++){ | |
| //change the value of first element | |
| if (index === 0) { | |
| prices[index] = prices[index] * 2; | |
| } | |
| //change the value of third element | |
| else if (index === 2) { | |
| prices[index] = prices[index] * 2; | |
| } | |
| //change the value of seventh element | |
| else if (index === 6) { | |
| prices[index] = prices[index] * 2; | |
| } | |
| } | |
| console.log(prices); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment