From 8af15b9e07833de1ff42621917983c0fb3d6ea48 Mon Sep 17 00:00:00 2001 From: Max Oleksyuk Date: Fri, 28 Jul 2023 10:10:31 +0300 Subject: [PATCH] I refracted the code --- src/makeRobot.js | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/src/makeRobot.js b/src/makeRobot.js index b591e03b..5754e0fe 100644 --- a/src/makeRobot.js +++ b/src/makeRobot.js @@ -54,39 +54,31 @@ function makeRobot(name, wheels, version) { return `${this.name}: x=${this.coords.x}, y=${this.coords.y}`; }, goForward(distance = 1) { - if (distance < 0) { - return this; + if (distance > 0) { + this.coords.y += distance; } - this.coords.y += distance; - return this; }, goBack(distance = 1) { - if (distance < 0) { - return this; + if (distance > 0) { + this.coords.y -= distance; } - this.coords.y -= distance; - return this; }, goRight(distance = 1) { - if (distance < 0) { - return this; + if (distance > 0) { + this.coords.x += distance; } - this.coords.x += distance; - return this; }, goLeft(distance = 1) { - if (distance < 0) { - return this; + if (distance > 0) { + this.coords.x -= distance; } - this.coords.x -= distance; - return this; }, evacuate() {