i taking javascript pre-bootcamp coding assessment require me receive input console. working repl.it online ide specified in assessment , can see button input right there on compiler, don't know how make program receive inputs console. here question.
write program accepts sequence of comma-separated numbers console , and generates (n m) of n times m = input_number matrix based on number of input given. suppose following input supplied program: 34,67,55,33,12,98 → 6 input. then, output should 2 by 3 matrix or a 3 by 2 matrix since both multiplication equals to 6 the total number of inputs: sample output [[34, 67], [55,33], [12,98]] or [[34,67,55],[33,12,98]]
find below code..
let input; let output = []; let divisor; let arraylength= input.length; let noofrows; if(arraylength == 1) { output = input; } else{ (let = 2; <= input.length; i++) if(arraylength % === 0){ divisor = i; break; } noofrows = arraylength / divisor; for(let =0; < noofrows; i++){ let splicedrow = input.splice(-divisor); output.push(splicedrow); } } console.log(output);
if type input ide, gives desired result. dont know how supply input console.
Comments
Post a Comment