competitive coding nodejs
/*
Sample addition code
Test cases file
2
2
10 20
3
10 20 30
*/
//Driver code
'use strict';
process.stdin.resume();
process.stdin.setEncoding('utf8');
let inputString = '';
let currentLine = 0;
process.stdin.on('data', inputStdin=>{
inputString += inputStdin;
})
process.stdin.on('end', ()=>{
inputString = inputString.trim().split("\n").map(string => {
return string.trim();
})
main();
})
function readline() {
return inputString[currentLine++];
}
function main() {
let t = parseInt(readline());
for(let i=0;i<t;i++) {
let n = parseInt(readline());
let arr = new Array(n);
let input_arr = readline().split(" ").map(x=> parseInt(x));
for(let j=0;j<n;j++) {
arr[j] = input_arr[j];
}
let sol = solution(arr);
console.log(sol);
}
}
//solution start here
function solution(arr) {
let result = 0;
for(let i=0;i<arr.length;i++) {
result += arr[i];
}
return result;
}