TypeScript bootcamp · Lab 33

Zip sums

mediumArray Methods12 minLesson: Array Methods

Read the question, write TypeScript on the right, then Run or Check.

QuestionHint and solution stay closed until you open them

Read two equal-length integer lines. Log pairwise sums space-separated.

Input. Two lines.

Output. Pairwise sums.

Examples

Example 1
Input
1 2 3
10 20 30
Output
11 22 33
Hint
  1. a.map((x,i) => x + b[i])
Show correct code

Peek only after you have tried. You can still Check your own version.

const a = readLine().trim().split(/\s+/).map(Number);
const b = readLine().trim().split(/\s+/).map(Number);
console.log(a.map((x, i) => x + b[i]).join(' '));
main.tstsc · readLine() · Ctrl + Enter
ResultIdle
Run to see output. Check grades the tests.