let example = document.createElement("p");
and now I want to add a new class to the p (<p>) that I just created.
You can try it this way:
// create node
const node = document.createElement('p');
// add id
node.setAttribute('id','new_id');
// add class
node.setAttribute('class', 'new-class');
example.className = "anyClass"