bonjour,

je suis entrain d'apprendre le javascript par moi meme, j'ai trouver un cours en anglais, mais je n'ai pas les solutions.
Je cherche quelqu'un qui pourrait faire c'est exercice et que je les compares pour voir les facon différentes, pour comprendre mes erreurs....

voici un premier énnoncé:

write a JavaScript program that prompts the user to enter 1 if they want to register as a new customer; and 2 if they are an established customer. If the user inputs anything other than 1 or 2, the system prompts them to try again. Do not use a loop: if the input is still not valid after two tries, the program does not produce any output.
Once a user has successfully entered 1 or 2, your system should print a welcome message. New customers should get the message “WELCOME – WE WILL SET UP YOUR ACCOUNT DETAILS NOW”; established customers will just get the message “SHOP UNTIL YOU DROP”.


et voici ma solution, mais j'ai un problème dedans:


Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<SCRIPT>
 
language="JavaScript"
type="text/javascript">
 
var customer;
 
customer = window.prompt('Please enter 1 to register as a new customer or 2 for estabisched customer','');
 
if (customer == 1)
{
document.write('<BR>' + 'WELCOME – WE WILL SET UP YOUR ACCOUNT DETAILS NOW')
}
else
{
if (customer == 2)
{
document.write('<BR>' + 'SHOP UNTIL YOU DROP')
}
else
{
document.write('<BR>' + 'Try again')
window.prompt('Please enter 1 to register as a new customer or 2 for estabisched customer','');
 
if (customer == 1)
{
document.write('<BR>' + 'WELCOME – WE WILL SET UP YOUR ACCOUNT DETAILS NOW')
}
else
{
if (customer == 2)
{
document.write('<BR>' + 'SHOP UNTIL YOU DROP')
}
}
}
}
 
 
</SCRIPT>