Multiply each item of a array into a new array except the length

I’m studying javascript but I get stuck in a exercise for like 3 days.

In tests, the first line of the input files contains an integer n, which denotes the number of elements in a array odds. each row i of the subsequent n rows (where 0 <= i < n), contains an integer describing odds[i] where i >= 0 and i < n.

test examples:

input: 5 2 3 5 8 10
output: 6 9 15 24 30

where: odds = [2, 3, 5, 8, 10]
its length is 5
and the result is the multiplication of each item ignoring the length number.

the code:

'use strict';

const fs = require('fs');


let inputString = '';
let currentLine = 0;

process.stdin.on('data', function(inputStdin) {
inputString += inputStdin;

process.stdin.on('end', function() {
inputString = inputString.split('\n');


function readLine() {
return inputString[currentLine++];

 	1. Complete the 'tripleTheChances' function below.
    2. The function's return is a variable of type INTEGER_ARRAY.
    3. The function accepts the odds parameter of type INTEGER_ARRAY.

function tripleTheChances(chances) {
// enter your code here
   const multiplyByThree = =>  item* 3)

function main() {
const ws = fs.createWriteStream(process.env.OUTPUT_PATH);

const chancesCount = parseInt(readLine().trim(), 10);

let chances = [];

for (let i = 0; i < chancesCount; i++) {
    const chancesItem = parseInt(readLine().trim(), 10);

const result = tripleTheChances(chances);

ws.write(result.join('\n') + '\n');


I try many different ways, but only one of the 5 tests is returning right. I think that at the end I have use a loop for this instead of a but I can figure out how.

From the description sounds like using map should be okay. What the function is returning?

its returning a join() error, I think it should be a for loop for what the explanation is saying but I dont know how.

I meant what tripleTheChances is returning?

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.