Challenge: Halve the Elements of the Array

Here is a coding challenge to test your understanding of arrays and slices.

We'll cover the following

Problem statement #

Iterate over the elements of an array of doubles and halve the ones that are greater than 10. Although there are many solutions to this problem, try to use only the features of slices.

Input #

double[] array = [ 1, 20, 2, 30, 7, 11 ];

Output #

1 10 2 15 7 5.5

Get hands-on with 1200+ tech skills courses.