We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • Hackerrank Home
  • Prepare
    NEW
  • Certify
  • Compete
  • Career Fair
  • Hiring developers?
  1. Prepare
  2. Tutorials
  3. 10 Days of Javascript
  4. Day 5: Arrow Functions

Day 5: Arrow Functions

Problem
Submissions
Leaderboard
Discussions
Editorial
Topics

Objective

In this challenge, we practice using arrow functions. Check the attached tutorial for more details.

Task

Complete the function in the editor. It has one parameter: an array, . It must iterate through the array performing one of the following actions on each element:

  • If the element is even, multiply the element by .
  • If the element is odd, multiply the element by .

The function must then return the modified array.

Input Format

The first line contains an integer, , denoting the size of .
The second line contains space-separated integers describing the respective elements of .

Constraints

  • , where is the element of .

Output Format

Return the modified array where every even element is doubled and every odd element is tripled.

Sample Input 0

5
1 2 3 4 5

Sample Output 0

3 4 9 8 15

Explanation 0

Given , we modify each element so that all even elements are multiplied by and all odd elements are multipled by . In other words, . We then return the modified array as our answer.

Author

AvmnuSng

Difficulty

Easy

Max Score

15

Submitted By

62650

Need Help?


View discussions
View editorial
View top submissions
RESOURCES

  • Arrow Functions in JavaScript

rate this challenge

MORE DETAILS

Download problem statement
Download sample test cases
Suggest Edits
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy