Created
December 18, 2020 19:44
-
-
Save peaceintheheart/1059c0c48172082471a87b0966bae06a to your computer and use it in GitHub Desktop.
A solution
This file contains 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
function findMyCampsites (campgrounds, viewToMatch, partySizeToMatch){ | |
let dreamSite =[]; | |
let sorryMessage = "Sorry, no campsites with that view are available to host your party"; | |
for (let i = 0; i< campgrounds.length; i++){ | |
if (campgrounds[i].isReserved === false && | |
campgrounds[i].view === viewToMatch && | |
campgrounds[i].partySize >= partySizeToMatch){ | |
dreamSite.push(campgrounds[i].number); | |
} | |
} | |
if (dreamSite.length == 0) { | |
return sorryMessage; | |
} | |
return dreamSite; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment