Created
November 30, 2019 07:32
-
-
Save jimmycrequer/0f7c1e708e30e3cba275d13efd4c82be to your computer and use it in GitHub Desktop.
geography-guesscontryfromcapital
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
async function guessCountryFromCapital() { | |
await session | |
.run(` | |
MATCH p = (:Country)<-[:IS_CAPITAL_OF]-(:City) | |
RETURN apoc.coll.randomItem(collect(p)) AS p | |
`) | |
.then(res => { | |
const p = res.records[0].get('p') | |
const capitalName = p.end.properties.name | |
const countryName = p.start.properties.name | |
const answer = readlineSync.question(`Which country has ${capitalName} as capital?\n> `) | |
if (answer == countryName) | |
console.log('\x1b[32m%s\x1b[0m', 'Correct!') | |
else | |
console.log('\x1b[33m%s\x1b[0m', `Wrong! The answer is ${countryName}.`) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment