Square at Alternate Indices
Sample Input 1
[ 1, 2, 3, 4, 5 ]
Sample Output 1
[ 1, 2, 9, 4, 25 ]
Sample Input 2
[ 2, 4 ]
Sample Output 2
[ 4, 4 ]
<script>
let arr = [1,2,3,4,5,6,7]
for (let i = 0; i < arr.length; i++) {
console.log(arr[i]*arr[i]);
}
</script>
Comments
Leave a comment