var num = 0; if (num != 0) { document.write('<span class="badge">'+num+'</span>'); } else { console.log(''); }