6 Replies - 775 Views - Last Post: 23 February 2014 - 01:51 PM

#1 Relaxed_Bear  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 03-January 14

if / else / alert

Posted 03 January 2014 - 04:47 PM

Hello dim members,

I'm new here and this is my first topic on this forum. I've recently started learning Javascript and I have a question.

var x = prompt("Password please?")

if ( x === "LOL" )
alert("Welcome!");
else
prompt("Please try again");

First of all, are their any syntax faults,.. in my code? And how can I make it so when the user writes something wrong it asks to try it again? My english sure ain't the best, my native language is dutch ;).

Is This A Good Question/Topic? 0
  • +

Replies To: if / else / alert

#2 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3480
  • View blog
  • Posts: 11,870
  • Joined: 12-December 12

Re: if / else / alert

Posted 03 January 2014 - 04:53 PM

Quote

First of all, are their any syntax faults,.. in my code?

Run the code. If it works there are no syntax errors.

You need to investigate loops if you want it to ask again.

BTW That should be DIC members (I hope..).

This post has been edited by andrewsw: 03 January 2014 - 04:54 PM

Was This Post Helpful? 0
  • +
  • -

#3 Relaxed_Bear  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 03-January 14

Re: if / else / alert

Posted 03 January 2014 - 04:58 PM

My mistake, indeed DIC members >.<. I've seen different kind of loops: for loops, while loops, .. which one exactly or just learn them all?
Was This Post Helpful? 0
  • +
  • -

#4 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3541
  • View blog
  • Posts: 10,236
  • Joined: 08-June 10

Re: if / else / alert

Posted 03 January 2014 - 05:02 PM

learn all of them, they’re basic syntax, after all.
Was This Post Helpful? 0
  • +
  • -

#5 no2pencil  Icon User is online

  • Toubabo Koomi
  • member icon

Reputation: 5314
  • View blog
  • Posts: 27,220
  • Joined: 10-May 07

Re: if / else / alert

Posted 03 January 2014 - 05:08 PM

** renamed topic to be more descriptive **

Please don't name your topic 'simple question'. This is a coding forum, & most topics here are questions.
Was This Post Helpful? 0
  • +
  • -

#6 Relaxed_Bear  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 03-January 14

Re: if / else / alert

Posted 04 January 2014 - 05:20 AM

Ofcourse ;)

This post has been edited by Dormilich: 04 January 2014 - 06:44 AM

Was This Post Helpful? 0
  • +
  • -

#7 felgall  Icon User is offline

  • D.I.C Head

Reputation: 15
  • View blog
  • Posts: 148
  • Joined: 22-February 14

Re: if / else / alert

Posted 23 February 2014 - 01:51 PM

If the place you are learning from is teaching alert() and prompt() then it is way out of date. You shouldn't be using either of those in Javascript any more - they were reporposed for debugging use (with extra checkboxes added) after Netscape 4 died and have not even been needed for that use since all browsers now have built in debuggers.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1