Take the 2-minute tour ×

I was reading this smooth CoffeeScript book and it had a code

confirm 'Shall we, then?', (answer) -> show answer

This is supposed to get the answer from the confirm and show it / I changed the 'show' to console.log and it doesn't seem to execute it. what am I missing.


share|improve this question
Changed what to console.log? Your question is unclear regarding what unexpected thing is happening to confuse you. –  Alex Wayne Jan 23 '12 at 18:44
add comment

1 Answer

up vote 3 down vote accepted

confirm() doesn't take a callback. Unless this guy made his own confirm function, that won't work. The cs for that compiles to

confirm("Shall we, then?", function(answer) {
  return console.log(answer);

confirm() returns true or false, so you can just use it as a conditional.

console.log "They answered yes" if confirm "Shall we, then?"
share|improve this answer
add comment

Your Answer


