Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Follow Instructions solution in Uncategorized category for Follow Instructions by Elena_Korljukova
import assert from "assert";
function follow(instructions: string): [number, number] {
var x = instructions.replace(/[l]/g, '').length - instructions.replace(/[r]/g, '').length;
var y = instructions.replace(/[b]/g, '').length - instructions.replace(/[f]/g, '').length;
return [x, y];
}
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!");
July 3, 2020