marishka88,
function getLocation(coordinates, commands) {
let [x, y] = coordinates;
for (let command of commands) {
if (command === 'forward') {
y++; //y += 1
}
if (command === 'back') {
y--; //y -= 1
}
if (command === 'right') {
x++; //x += 1
}
if (command === 'left') {
x--; // x -= 1
}
}
return [x, y]
}
let coordinates = [2, 1],
commands = ['left', 'back', 'back']
alert(getLocation(coordinates, commands));