I'm recieving 2-dimensional positions of two objects as a string with this format:
x1,y1,x2,y2. The string is recieved from a
readline call (replaced in the snippet with a
In order to get the horizontal and vertical position differentials, I'm writing the following code:
[x1,y1,x2,y2]=prompt("Please enter the positions separated by commas").split`,` dx=+x2-x1 dy=+y2-y1 console.log(dx,dy)
Is there a way to get
dy using less characters since I don't really need the positions? I suppose the main problem could be in the variable assignment which can probably be done in one step. I can use ECMAScript 6.
I don't really know if I have to precise it but removing the text in the prompt or giving variables 1-char names doesn't count, I have written them on purpose to clarify my question. The
console.log is not part of the code golf either since the variables are supposed to be used after in the program.