I have a piece of code such as image.alt = result.title and image.alt = result.explanation. How do I combine the explanation to the title?
// Image
const image = document.createElement("img");
image.src = result.url;
image.alt = result.title
image.loading = "lazy";
image.classList.add("card-img-top");
Apologies for the newbie question
You have to concat 2 strings. In Javascript, you could do it with + operator like that:
image.alt = result.title + ' ' + result.explanation;
As you see in the example, I've also added ' ' which is space between two values.