JS Function not working

I know this might be dumb, but this code won’t display when reloaded:

function addApp() {
  // Get user input for the variables
  const title = prompt("Enter the title:");
  const src = prompt("Enter the source:");
  const img = prompt("Enter the image URL:");
  const name = prompt("Enter the name:");

  // Create a new button element
  const button = document.createElement('button');

  // Create a new anchor element and set its attributes
  const anchor = document.createElement('a');
  anchor.className = 'app';
  anchor.onclick = function() {
    openWindow(title, src);

  // Create a new image element and set its source attribute
  const image = document.createElement('img');
  image.src = img;

  // Create a new paragraph element and set its text content
  const paragraph = document.createElement('p');
  paragraph.className = 'namething';
  paragraph.textContent = name;

  // Append the image and paragraph elements to the anchor element

  // Append the anchor element to the button element

  // Append the button element to the document body

  // Save the resulting HTML to localStorage
  localStorage.setItem('savedHTML', document.body.innerHTML);

  // Retrieve the saved HTML from localStorage
  const savedHTML = localStorage.getItem('savedHTML');

  // If there is saved HTML, display it on the page
  if (savedHTML) {
    document.body.innerHTML += savedHTML;

Please format your post in triple back ticks. This will make it easier for us to understand and help you with your code.


Hello @ChickenG1ttrDev! Please edit your post’s code to be formatted like this:

Your code here

So that it is easier for staff and members of the community to help you with your issue!

PS: if you cannot edit your post, please read around a little to increase your trust level and let you access editing your posts.

Also see this guide on how to share your code: