#Java script help with build your own burger lmk if it needs work or what I should fix.

6 messages · Page 1 of 1 (latest)

proven mural
#

// Wait for the page to load
window.onload = function() {
// Create the menu
var menu = document.createElement("div");
menu.id = "menu";
menu.style.display = "flex";
menu.style.justifyContent = "center";
menu.style.gap = "20px";
menu.style.margin = "20px";
document.body.appendChild(menu);

// Create the plate
var plate = document.createElement("div");
plate.id = "plate";
plate.style.width = "300px";
plate.style.height = "300px";
plate.style.border = "2px solid black";
plate.style.backgroundColor = "#f5f5dc";
plate.style.margin = "20px auto";
document.body.appendChild(plate);

// List of ingredients
var ingredients = ["bun_top.png", "patty.png", "cheese.png", "lettuce.png", "bun_bottom.png"];

// Add each ingredient to the menu
for (var i = 0; i < ingredients.length; i++) {
var img = document.createElement("img");
img.src = ingredients[i];
img.style.width = "100px";
img.style.cursor = "grab";

// Store the image source to use in the click function
img.setAttribute("data-src", ingredients[i]);

// Add click function to each ingredient
img.onclick = function() {
  var copy = document.createElement("img");
  copy.src = this.getAttribute("data-src");
  copy.style.display = "block";
  copy.style.margin = "auto";
  plate.appendChild(copy);
};

menu.appendChild(img);

}
};

fierce pendant
#

feels ChatGPT

#

but looks okay-ish if you're into writing 10 year old code ig

rancid sonnet
#

yup as rob says, old code style, still iirc is getting tought as basic a lot on websites.

fierce pendant
#

Yeah could be as well

#

still smells like an LLM output