I'm trying to make an app that displays code snippets, for that, I'm creating a data array (so that I can use a map function on that data to display a list of code)
it should contain the following contents -
const data = [
{
id: 1,
code: "The code goes here.",
},
];
However, whenever I try to enclose this snippet -
javascript: (() => {
var word = prompt(`Please enter the word here. `);
const call = async (word) => {
const request = await fetch(
`https://www.dictionaryapi.com/api/v3/references/thesaurus/json/${word}?key=`
)
.then((response) => response.json())
.then((data) => {
const synArray = data[0].meta.syns[0];
window.alert(synArray);
});
};
call(word);
})();
In double quotes or single quotes. It does not work. I want exactly this snippet to be stored in a variable. I don't want to change the single quotes or any other thing in the code itself.