There is a problem with the following code: I tried to create an element in javascript but the element appears and disappears each time a click is performed.
function hi() {
  let user = document.getElementById('username').value;
  let email = document.getElementById('email').value;
  let password = document.getElementById('password').value;
  let cpassword = document.getElementById('cspassword').value;
  if (user == "" || email == "" || password == "" || cpassword == "") {
    alert('no field can be left empty')
  } else if (password != cpassword) {
    let par = document.createElement('p');
    let text = document.createTextNode('passwords do not match');
    par.appendChild(text);
    document.querySelector('form').appendChild(par);
  } else {
    alert('welcome');
  }
}<!DOCTYPE html>
<html>
<head>
  <title>forms</title>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-compatible" content="ie=edge">
</head>
<body>
  <form class="myform">
    <input type="text" placeholder="username" id="username" name="">
    <input type="email" placeholder="Email" id="email" name="email">
    <input type="password" placeholder="password" id="password" name="password">
    <input type="password" placeholder="cpassword" id="cspassword" name="cpassword">
    <button onclick="hi();">submit</button>
  </form>
  <script src="forms.js"></script>
</body>
</html>The expected behavior should be the creation of a paragraph if the password is incorrect.
 
     
     
     
    