import * as std from 'std'; var names = std.loadFile('22_names.txt').replaceAll(/"/g, '').split(','); names = names.sort(); var sum = 0; names.forEach(function(n,i) { var score = 0; n = n.toUpperCase().split('').map(c => c.charCodeAt(0)); n.forEach(c => score += (c-64)); sum += (score*(i+1)); }); console.log(sum);