Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function validityChecker(x1, y1, x2, y2) {
- function isValid(x1, y1, x2, y2) {
- const distance = Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2));
- if (Number.isInteger(distance)) {
- console.log(`{${x1}, ${y1}} to {${x2}, ${y2}} is valid`);
- } else {
- console.log(`{${x1}, ${y1}} to {${x2}, ${y2}} is invalid`);
- }
- }
- isValid(x1, y1, 0, 0);
- isValid(x2, y2, 0, 0);
- isValid(x1, y1, x2, y2);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement