警报文本和变量 JavaScript

alert text & variable JavaScript

我可以把文本和变量放在同一个警告框中吗 我以为下面的代码可以工作,但没有

alert('text'Variable);

alert('Your text goes here'+your var goes here);

我找到了我应该放的代码

var name = "John Doe";

function myFunction() {
  alert('Hello ' + name);
}
<button onclick="myFunction()">Checkout</button>