1

I am writing a simple calculator that calculates income made, income spent on food, housing, etc. I want to make the header change to: Budget analysis for "Name Here" Using:

var Name=prompt("Enter Your Name.","Name")

How would I do this

Barmar
  • 741,623
  • 53
  • 500
  • 612
  • See also https://stackoverflow.com/questions/1358810/how-do-i-change-the-text-of-a-span-element-using-javascript – NineBerry Apr 14 '21 at 16:37
  • The proposed answers do not fully answer question OP. Since the OP also needs to show a method for concatenating a static string with a variable. – s.kuznetsov Apr 14 '21 at 17:15

1 Answers1

1

document.addEventListener("DOMContentLoaded", function(){
  var Name = prompt("Enter Your Name.","Name");
  document.getElementById('name').innerHTML = Name;
})
<h1>Budget analysis for <span id="name"></span></h1>
Tariqul Islam
  • 347
  • 4
  • 18