Convert a decimal number to a string

VPN/Proxy erkannt

Es scheint, dass Sie einen VPN- oder Proxy-Dienst verwenden. Bitte beachten Sie, dass die Nutzung eines solchen Dienstes die Funktionalität dieser Webseite einschränken kann.

  • Hello everyone, sorry for the trivial question: how can I convert a decimal number to a string?

    I'm trying to use "MQTT.publish (topic, message, qos, retain)" to send the measured power value (res.apower) where the "message" must obviously be a string.

    A thousand thanks.

  • Code
    let my_int = 2;
    let my_float = 3.14;
    let my_string = "values: " + JSON.stringify(my_int) + ", " + JSON.stringify(my_float);

    will produces the string "values: 2, 3.14"