Hi there
I'm trying to convert Decimal to Hex with raw code as a challenge someone gave me but im struggling to figure out why the the payload that's shown in the debug node is "undefined".
Thank you in advance for the help
Kind Regards
Apple
[{"id":"d3a188d4.8d7a5","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"b4480307.eea488","type":"ui_tab","name":"Text","icon":"dashboard","disabled":false,"hidden":false},{"id":"74716359.e24674","type":"ui_base","theme":{"name":"theme-light","lightTheme":{"default":"#0094CE","baseColor":"#0094CE","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif","edited":false},"darkTheme":{"default":"#097479","baseColor":"#097479","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif","edited":false},"customTheme":{"name":"Untitled Theme 1","default":"#4B7930","baseColor":"#4B7930","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif"},"themeState":{"base-color":{"default":"#0094CE","value":"#0094CE","edited":false},"page-titlebar-backgroundColor":{"value":"#0094CE","edited":false},"page-backgroundColor":{"value":"#fafafa","edited":false},"page-sidebar-backgroundColor":{"value":"#ffffff","edited":false},"group-textColor":{"value":"#1bbfff","edited":false},"group-borderColor":{"value":"#ffffff","edited":false},"group-backgroundColor":{"value":"#ffffff","edited":false},"widget-textColor":{"value":"#111111","edited":false},"widget-backgroundColor":{"value":"#0094ce","edited":false},"widget-borderColor":{"value":"#ffffff","edited":false},"base-font":{"value":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif"}},"angularTheme":{"primary":"indigo","accents":"blue","warn":"red","background":"grey","palette":"light"}},"site":{"name":"Node-RED Dashboard","hideToolbar":"false","allowSwipe":"false","lockMenu":"false","allowTempTheme":"true","dateFormat":"DD/MM/YYYY","sizes":{"sx":48,"sy":48,"gx":6,"gy":6,"cx":6,"cy":6,"px":0,"py":0}}},{"id":"47c654c9.b93774","type":"ui_group","name":"TextInput","tab":"b4480307.eea488","order":1,"disp":true,"width":"6","collapse":false},{"id":"f907f557.afb4e8","type":"ui_tab","name":"IP","icon":"dashboard","disabled":false,"hidden":false},{"id":"23ae81f3.a18136","type":"ui_group","name":"IPInput","tab":"f907f557.afb4e8","order":1,"disp":true,"width":"6","collapse":false},{"id":"c777dfe0.1979c","type":"inject","z":"d3a188d4.8d7a5","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"123","payloadType":"str","x":110,"y":100,"wires":[["4cd0ed56.445ecc"]]},{"id":"4cd0ed56.445ecc","type":"function","z":"d3a188d4.8d7a5","name":"","func":"var val = msg.payload;\nvar res;\nvar numval =\"\";\nvar hexval;\nvar endval;\nvar Hex = new Array(16);\nHex[0] = 0;\nHex[1] = 1;\nHex[2] = 2;\nHex[3] = 3;\nHex[4] = 4;\nHex[5] = 5;\nHex[6] = 6;\nHex[7] = 7;\nHex[8] = 8;\nHex[9] = 9;\nHex[10] = \"A\";\nHex[11] = \"B\";\nHex[12] = \"C\";\nHex[13] = \"D\";\nHex[14] = \"E\";\nHex[15] = \"F\";\nwhile(res > 0)\n{\n res = val%16;\n for(i=0;i<10;i+1)\n {\n if(res == Hex[i])\n {\n numval = res + numval;\n }else if (res<9>16)\n {\n hexval = Hex[res];\n }\n }\n val = val/16;\n}\nendval = numval+hexval;\nmsg.payload = {payload:endval};\n\n\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":260,"y":140,"wires":[[]]},{"id":"539cd750.5ac72","type":"debug","z":"d3a188d4.8d7a5","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":530,"y":100,"wires":[]}]