To test if there is no ID attribute, could be something like:
if (!formatting.getAttribute("id"))
{//do this};
To test it's value just pass it to a var and then the usual javascript methods apply for example:
var myAttr = formatting.getAttribute("id");
if (myAttr == 'yes') {//do this}
else if (myAttr => 10) {//do that}