Created
September 11, 2023 08:31
-
-
Save codeperfectplus/d4f4140a8c2972064192f50a7598215e to your computer and use it in GitHub Desktop.
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
| function modifyArray(nums) { | |
| // iterate through the array | |
| for(let i=0;i<nums.length;i++) { | |
| // all even elements are doubled | |
| if(nums[i] % 2 == 0){ | |
| nums[i]*=2; | |
| // all odd elements are tripled | |
| }else{ | |
| nums[i]*=3; | |
| } | |
| } | |
| // return array | |
| return nums; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment