aboutsummaryrefslogtreecommitdiff
path: root/challenge-279/zapwai/javascript/ch-1.js
blob: 90e00128a6752910812e2f39e72645dbcc84a80f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
let letters = ['R', 'E', 'P', 'L'];
let weights = [3, 2, 1, 4];
proc(letters, weights);
letters = ['A', 'U', 'R', 'K'];
weights = [2, 4, 1, 3];
proc(letters, weights);
letters = ['O', 'H', 'Y', 'N', 'P', 'T'];
weights = [5, 4, 2, 6, 1, 3];
proc(letters, weights);

function proc(l, w) {
    console.log("Input: letters, weights", l, w);
    let ans = [];
    for (let i = 0; i < l.length; i++) {
	ans[w[i] - 1] = l[i];
    }
    console.log("Output: ", ans);
}