How to display something if variable is not set inside a each loop?
<pre><code>$.each(json.data,function(i,fb){

//some code here...

if (msg.length &gt; 150) {
                msg = msg.substr(0,200)+"...";
            }

//more code here...
});
</code></pre>

<p>I have an issue here. If msg is not defined I got an error and I got nothing displayed on the browser.</p>

<p>Possible Solution: create a default message for the cases where msg is not defined.</p>

<p><strong>Try:</strong></p>

<pre><code>if (msg = 'undefined') {
 msg = 'some default message';
} else if (msg.length &gt; 150) {
msg = msg.substr(0,200)+"...";
}
</code></pre>

<p><strong>Issue:</strong>
The above try didn't work because I get for each item, the same default message, instead of having the default message only for those cases were msg is no "set". </p>

<p><strong>Request:</strong>
Can I have your help in order to write the proper code so that, on each item, if msg is not defined show a default one, if otherwise, it's site, display it ?</p>

<p>If you lack some information in order to proper help me, please, let me know. I'm really on a bad position right now. :s</p>

<p>Thanks a lot,
MEM</p>
