I forgot to add that perhaps if your PC has already paired with the device, that pairing could be stored in memory and so it may not ask you for a passcode. You could try connecting with another device?
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Yes, that code looks spot on.
I forgot to add that perhaps if your PC has already paired with the device, that pairing could be stored in memory and so it may not ask you for a passcode. You could try connecting with another device?