-4

So, I want to make a javascript bookmarklet that starts a prompt to type in a password. if the password is correct it will alert a secret message. I put together some code from my other bookmarklets, and made this:

javascript: prompt("Password?");if(12345) alert(Correct)

But alas, it doesn't work. The only javascript experience i have is tinkering a little with a bunch of bookmarklets so...

Justin Pearce
  • 4,994
  • 2
  • 24
  • 37
  • 1
    Try: `javascript:prompt("Password?")==12345&&alert("Correct")` but what is the use when the password (`12345`) is in there ? – Titus May 11 '18 at 20:29
  • try: `prompt("Password?") === 12345 ? alert("Correct") : ""` – mhodges May 11 '18 at 20:29

1 Answers1

0

This will work for tinkering etc. It is not actually secure.

let password = prompt('Password?');
if (password === 'asdf') {
  alert('correct');
}

W3schools has a good JavaScript intro series: https://www.w3schools.com/js/default.asp

James Parsons
  • 6,097
  • 12
  • 68
  • 108
tmurphree
  • 79
  • 2
  • 11