Uncaught SyntaxError: Identifier 'txt' has already been declared

Hello guys,
In the cell of a table I want to display instead of a letter a character but in my testprogram I have problems to display correct my output.
When I start the program it works. But when I change the x and y nothing happen...
In the developer tools from the browser (f12) i found the error: "Uncaught SyntaxError: Identifier 'txt' has already been declared".
I don't have other variables with the same name.
What did I do wrong?
Thank you so much in advance!

<!--<div ng-bind-html="msg.payload"></div>-->

        #table-test td {
            width: 40px;
            height: 40px;
<table id="table-test">

    cellX = 0, cellY = 0; 
    var theTable = document.getElementById('table-test'), 
    theCell = theTable.rows[cellY].cells[cellX],
    wCell = theCell.offsetWidth, hCell = theCell.offsetHeight;
    theCell.style.position = 'relative';
    theCell.innerHTML = '';
    let txt = document.createTextNode('**');

when you call it the second time - the let txt= is already declared from the first time so it causes the error. You notice that you don't declare let cellX= or any of the other variables the same way.

Thank you so much for your fast help.
Now I leave out the comand "let" on the variable txt and it works.
How I access to msg object in javascript? I found this but I' m not an excpert and so I have difficult to understand it... I get allways the error: "msg is not defined"
How i have to write the code to access to the msg object?
Thanks for our help!
For example I have this testcode:

var a = msg.payload.a[1].test;
switch (a){
  case 1:
case 2:

Remember that Dashboard uses Angular so the msg object is buried inside the Angular environment.

I wrote a blog post about it a long time ago:

Thank you for your help.
For me is AngularJS new :woozy_face: but I will try to understand your sourcecode on your blog and apply it to my testcode. :cowboy_hat_face:

1 Like