Created
December 11, 2022 12:57
-
-
Save mathemagie/75595b3ea075d7a93873edd4bee4da12 to your computer and use it in GitHub Desktop.
ineBedWithThomasPesquet.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This code will make vibrate the whole of the connected sextoys present on Earth with the overflight of the International Space Station above France | |
// Create a constant to store coordinates for France | |
const FRANCE_COORDINATES = {lat: 46.2276, long: 2.2137}; | |
// Function to get current location of ISS | |
function getISSLocation() { | |
// Fetch data from API endpoint for ISS location info | |
let response = await fetch('http://api.open-notify.org/iss-now.json'); | |
// Parse response into JSON object and return it const issLocationData = await response.json(); return issLocationData; } | |
// Function to check if ISS is above France function isISSAboveFrance(isslocation) { | |
// Get latitude and longitude from ISS location data let lat = isslocation['latitude']; let lon = isslocation['longitude']; | |
// Check if coordinates are within bounds of France's coordinates if (lat > FRANCE_COORDINATES['lat'] && lat < FRANCE_COORDINATES['lon']){ return true; } else { return false; } } | |
// Function to activate all connected sextoys when ISS passes over France function activateSextoys(){ console.log('Activating all connected sextoys...') } | |
// Main program logic async function main(){ while(true){ const issLocationData= await getISSLocation(); let isISSAboveFranceResult=isISSAboveFrance(issLocationData); if (isISSAboveFranceResult) { activateSextoys(); }; }; }; main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment