I got an easy question hopefully someone can help out with.
Im working on doing catching rolls from chat, such as [[1d20+10]], which works fine.
My problem is how to check to see if part of that roll is 'undefined' before processing that part..to stop Cannot Read errors.
For example I got a part called
var mod = (r.results.rolls[1].expr);
which returns the +10 to display their modifier..works great.
How do I check if it exists, and if none make var mod = '0', Anything I tried of doing 'if == undefined', 'if == null' ect.. brings me back to it saying it doesnt know what it is, to check it in the first place.
Im working on doing catching rolls from chat, such as [[1d20+10]], which works fine.
My problem is how to check to see if part of that roll is 'undefined' before processing that part..to stop Cannot Read errors.
For example I got a part called
var mod = (r.results.rolls[1].expr);
which returns the +10 to display their modifier..works great.
problem is if they roll [[1d20]] I get a 'Cannot read property 'expr' as undefined.'
How do I check if it exists, and if none make var mod = '0', Anything I tried of doing 'if == undefined', 'if == null' ect.. brings me back to it saying it doesnt know what it is, to check it in the first place.