<button>PROMPT</button>
button {
  font-size: 1.5rem;
  padding: 0.4em 1em;
}

body {
  display: grid;
  place-items: center;
  min-height: 100dvh;
}
const button = document.querySelector("button")
button.addEventListener("click", () => {
  const name = prompt("이름을 입력하세요:", "홍길동");
  if (name) {
    button.textContent = `반갑습니다, ${name}님! 😄`;
  } else {
    button.textContent = "이름을 입력하시지 않으셨습니다. 😢";
  }
})

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.