Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Problem z Pętlą.
DamianRastMan
post 14.01.2016, 20:03:56
Post #1





Grupa: Zarejestrowani
Postów: 26
Pomógł: 2
Dołączył: 3.04.2015

Ostrzeżenie: (0%)
-----


  1. <script>
  2. for (var number=99; number != 0; number-- )
  3. {
  4. var nextnumber = number-1;
  5. if(number > 2)
  6. {
  7. document.write("is "+number+" bottles of beer on the wall."+number+" bottles of beer. Take one down and pass it around - "+nextnumber+" bottles of beer on the wall. <br />");
  8. }
  9. else if(number = 2)
  10. {
  11. document.write("is "+number+" bottles of beer on the wall."+number+" bottles of beer. Take one down and pass it around - "+nextnumber+" bottle of beer on the wall. <br />");
  12. }
  13. else if(number = 1)
  14. {
  15. document.write("is "+number+" bottles of beer on the wall."+number+" bottle of beer. Take it down and pass it around - no more bottles of beer on the wall. <br />");
  16. }
  17. }
  18. </script>


Witam, dziś jest mój pierwszy dzień z JavaScript, wcześniej maczałem już palce w php i pewnie stąd mój bak zrozumienia... no więc.. Chciałbym aby ten kawałek kodu, wyświetlał mi znaną, szkocką, barową piosenkę: https://pl.wikipedia.org/wiki/99_Bottles_of_Beer, jednak niestety pojawia mi się tutaj problem.. i nie mogę dość, co to takiego? Będę bardzo wdzięczny za pomoc smile.gif

Okej, rozwiązany... problem tkwił w operatorze porównania... = zamiast == smile.gif

Ten post edytował DamianRastMan 14.01.2016, 19:57:54
Go to the top of the page
+Quote Post

Posty w temacie
- DamianRastMan   Problem z Pętlą.   14.01.2016, 20:03:56


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 14.08.2025 - 13:54