Skip to content

Message.forEach is not a function or some time undefined problem #47

@AvanishKumar008

Description

@AvanishKumar008
Details['11'] = {
            'id': '11',
            'name': 'Avanish'
        };
res.render('/index',{'Message': Details});

Page code

        <script>
           var ERRORCONST = 'Error';
           var NORECORDS = 'No records';
        </script>

<%if(Message != undefined && Message != NORECORDS && Message != ERRORCONST ){%>
<%Message.forEach(function(key){%>
<span><%= key.id %> - <%= key.name %></span>
<%});%>
<%}%>

Getting error ``NORECORDS is not defined`and print all code on page. I have two error. One is how to use Multiple condition in single if statement and second is how to compare javascript varibale with server variable

if i remove && Message != NORECORDS && Message != ERRORCONST after that getting error forEach not a function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions