its working for me
<script>
var foodDemand = function(food) {
alert(food);
};
foodDemand("Fried Chicken");
</script>
How to alert contents of console.log? [closed]
-
30-06-2022 - |
Question
I would like to alert/prompt the contents of console.log()
.
How to alert/prompt - console.log("I want to eat" + " " + food);
?
I tried alert("I want to eat" + " " + food);
but it does not seem to be valid.
e.g.
<script>
var foodDemand = function(food) {
console.log("I want to eat" + " " + food);
};
foodDemand("Fried Chicken");
</script>
How to alert/prompt - console.log("I want to eat" + " " + food);
?
I tried alert("I want to eat" + " " + food);
but it does not seem to be valid.
foodDemand("Fried Chicken");
yields in the console:
"I want to eat Fried Chicken"
How can i get the same with prompt();
or alert();
?
Solution
OTHER TIPS
It should work without any problems, as I can demonstrate with jsFiddle
note that you do not need to add the space separately, do it like this:
"I want to eat " + food
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow