• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# JS Advanced/Syntax,Functions and Statements/Valid Checker

GMincheva Nov 19th, 2019 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. function solve(arrInput){
2. let x1=arrInput[0];
3. let y1=arrInput[1];
4. let x2=arrInput[2];
5. let y2=arrInput[3];
6.
7. let firstToCsDistance =Math.sqrt(Math.pow(0-x1,2)+Math.pow(0-y1,2));
8. let secondToCsDistance =Math.sqrt(Math.pow(0-x2,2)+Math.pow(0-y2,2));
9. let firstToSecond = Math.sqrt(Math.pow(x2-x1,2)+Math.pow(y2-y1,2));
10. if(Number.isInteger(firstToCsDistance)){
11. console.log(`{\${x1}, \${y1}} to {0, 0} is valid`);
12. } else {
13.     console.log(`{\${x1}, \${y1}} to {0, 0} is invalid`);
14. }
15. if(Number.isInteger(secondToCsDistance)){
16.     console.log(`{\${x2}, \${y2}} to {0, 0} is valid`);
17.     } else {
18.         console.log(`{\${x2}, \${y2}} to {0, 0} is invalid`);
19.     }
20.
21. if(Number.isInteger(firstToSecond)){
22.     console.log(`{\${x1}, \${y1}} to {\${x2}, \${y2}} is valid`);
23.     } else {
24.             console.log(`{\${x1}, \${y1}} to {\${x2}, \${y2}} is invalid`);
25.     }
26. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top