Skip to content

Instantly share code, notes, and snippets.

@tennox
Last active June 16, 2021 09:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tennox/28d5d0f365b5ae2c50a911bdf7872dab to your computer and use it in GitHub Desktop.
Save tennox/28d5d0f365b5ae2c50a911bdf7872dab to your computer and use it in GitHub Desktop.
Can you reach the throne?

Can you reach the throne?

You (brian) are allowed to change the cleaning code, but nothing else.

Can you reach the throne?

JS Fiddle here

function foo() {
// Let the boy clean the castle
document.write("Cleaning")
// WRITE CLEANING CODE HERE
// END CLEANING CODE
document.write("<br/>")
// NOT ALLOWED TO CHANGE FROM HERE
const castle = (
name,
throneProof = undefined
) => {
document.write("Hello,", name, '<br/>')
if (throneProof != null) {
document.write("<strong>WELCOME TO THE THRONE!</strong><br/>")
} else {
document.write("<em>Keep cleanin', sucker!</em><br/>")
}
}
function guard(name) {
if (name === 'King') {
castle(name, true)
} else {
castle(name)
}
}
guard("King")
document.write("<br/>")
guard("brian")
}
foo()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment