0

我想提醒/提示console.log().

如何提醒/提示 - console.log("I want to eat" + " " + food);?我试过alert("I want to eat" + " " + food);了,但似乎无效。

例如

<script>
var foodDemand = function(food) {

  console.log("I want to eat" + " " + food);

};

foodDemand("Fried Chicken");
</script>

如何提醒/提示 - console.log("I want to eat" + " " + food);?我试过alert("I want to eat" + " " + food);了,但似乎无效。

foodDemand("Fried Chicken");在控制台中产生: "I want to eat Fried Chicken"

我怎样才能得到相同的prompt();or alert();

4

2 回答 2

1
   its working for me

 <script>
    var foodDemand = function(food) {

      alert(food);

    };

    foodDemand("Fried Chicken");
    </script>
于 2013-10-01T13:53:43.263 回答
0

正如我可以用jsFiddle演示的那样,它应该可以正常工作

请注意,您不需要单独添加空间,请这样做:

"I want to eat " + food

于 2013-10-01T13:53:00.323 回答