Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Third solution in Uncategorized category for Follow Instructions by vvm70
import assert from "assert";
function follow(instructions) {
let dir = (i, m = instructions.match(RegExp(i, 'g'))) => m ? m.length : 0;
return [dir('r') - dir('l'), dir('f') - dir('b')]
}
console.log('Example:');
console.log(follow('fflff'));
// These "asserts" are used for self-checking
assert.deepEqual(follow('fflff'), [-1, 4]);
assert.deepEqual(follow('ffrff'), [1, 4]);
assert.deepEqual(follow('fblr'), [0, 0]);
console.log("Coding complete? Click 'Check' to earn cool rewards!");
Jan. 6, 2021