4

Can I put both text and variable in the same alert box I thought the code down would work but it didn't

alert('text'Variable);

2
  • Where is Total defined? Please share your full code. Commented Mar 22, 2017 at 9:36
  • 1
    It WOULD work if you had defined Total somewhere Commented Mar 22, 2017 at 9:36

2 Answers 2

8

var name = "John Doe";

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

Sign up to request clarification or add additional context in comments.

Comments

4

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

I find out the code I should have put

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.