@Nickax, sad to hear your tough start... so lucky me, it was a no brainer to leave A..o (and other decade old fun with Z8) aline and enjoy very much iot w/ JS on Espruino.
To cut to the chase: copy-paste can have its issues since sometimes invisible rendering sequences make it into the code and mess it up.
Take a look at some of these conversations... Temperature Web Monitor (you going for BLE), Developing Modules... latter uses the DS18B20 but just as an example to discuss the topic.
Furthermore, as a general thing: 'never ever' - even though never ever say 'never ever' - do active things in level 0 - like
setInterval(... - ... it just calls for puzzling waste of time. Unfortunately, many of the examples do so... and just get lucky most of the time. Being wired while developing, such as for Espruino Original board, Pico, Espruino-WiFi,... luck is almost guaranteed (for the small examples). With Puck and Pixl, luck is just in short supply, because over the air - ota - may get impacted from the electro smog around you and delay completion of upload - and uploading of code and firing timeouts don't like each other - as they are setup on upload when in level 0.
Therefor, safest approach is using
onInit(), even though there are other avenues that make sure that uploading completes first because any other (of your application stuff) gets underway.
Take a look at simple explanation how to save code that espruino run on start? conversation. Even though a bit outdated, provides some insight what happens on upload and saving of code.
btw, if you put posted code between lines that have three (3) back-ticks (accent-grave) with a blank line before and after, your code because easy to read...