Claudio51

Código cantando os patinhos com array em javascript

Sep 23rd, 2021
84
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3. <!DOCTYPE HTML>
  4. <html>
  5.  <head>
  6.  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  7.  <title>Cantando os Patinhos - JAVASCRIPT</title>
  8.  </head>
  9.  <body style="background:#abcdef;font-family: arial;">
  10.  
  11.     <center><img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBxEQERIQDxAPEhIVEBMQEA8SEA8QDxcPFREWFhYTExUYHSggGBolGxUTITEiJSkrLi8uFx8zODUtNygtLisBCgoKDg0OGxAQGy0gICUtLS0vLi0tLS0tLy0uKy0tLS0tLy8tLS4tLTAtLS0tLS0tLS0tLS0tLS0tKy0tLS0tLf/AABEIAOEA4QMBEQACEQEDEQH/xAAbAAEAAgMBAQAAAAAAAAAAAAAABAUBAgMGB//EADsQAAIBAgIIBAIIBAcAAAAAAAABAgMRBCEFEjFBUWFxkQaBobEiMhMUQlJywdHwBzOS4RUjYoKisvH/xAAbAQEAAgMBAQAAAAAAAAAAAAAAAwQBBQYCB//EADURAQACAQIEAgkDAwQDAAAAAAABAgMEEQUSITFBUQYTIjJhcYGRoRRS0UKx4RUjM8EW8PH/2gAMAwEAAhEDEQA/APtIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADWc0ldtJcWR5c2PFXmvMRHxZiJnsh1dJxXypy9EaDUekunp0xxNvxCeuntPdxelJbox7tmut6UZvDHH3lJ+njzZjpR74LybR6p6UZP6scfSWJ00ebvS0jB7bx65rujZ6f0i0uTpfek/HsjtgtHbqlxknmmmuKN5TJXJXmpO8IZjbuye2AAAAAAAAAAAAAAAAAAAAAAAAA44rEKmrvbuXFlDiHEMejx81us+Eeb3S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OuG8T8J7/dYrqI8UaeEqLbB+WfsabLwnWYvexz9Ov8AZLGWs+Li1bbl1yKVsd6+9Ex9HveGDwyGAMxG43jTk9kW+ibJ8elzZPcpM/SXmbRHi708BUe5LqzZ4OAazJ3ry/OUc56wmUdGxXzNy5bEb3S+jWGnXNPN8O0IbaiZ7JsIpKySS4LI6HFipiry0iIj4IJmZ7skjAAAAAAAAAAAAAAAAAAAAAAAAHma1nvBu1dOP3V2RHOmwz3rH2hnmlj6KP3Y9kef0mD9kfaGeafNlQS2Jdke4w447Vj7Mby2JIjZgMgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//2Q==" alt="some text" width=100 height=100></center>
  12.  
  13.     <h1><center>Exerc&iacutecio com array e la&ccedilo for em Javascript</h1>
  14.     <h3><center><span style="color:red;">Cantando os patinhos</h3>
  15.        
  16.     <script>
  17.     /***************************************************************************
  18.      
  19.       Crie um algor?timo com a musica cantado os patinhos, da Xuxa,
  20.      
  21.       onde todas as frases estejam no array,
  22.      
  23.      ***************************************************************************
  24.      */
  25.    
  26.     const texto = [
  27.         ' patinho',
  28.         ' patinhos',
  29.         ' foi passear,',
  30.         ' foram passear,',
  31.         ' mais s&oacute ',
  32.         ' para al&eacutem das montanhas para brincar, a mam&atildee gritou',
  33.         ' voltou',
  34.         ' voltaram',
  35.         ' de l&aacute.',
  36.         '  QU&Aacute!',
  37.         ' mais nenhum'];
  38.    
  39.     for (n = 5; n >=1; n--){
  40.             if(n > 1){
  41.                 document.write(n + texto[1] + texto[3]  + texto[5]);
  42.             }else{
  43.                 document.write(n + texto[0] + texto[2]  + texto[5]);
  44.             }
  45.             for(x = 1; x<=4; x++){
  46.                 document.write(texto[9]);
  47.             }
  48.             if(n > 1){
  49.                 document.write(texto[4] + (n-1));
  50.                 if(n > 2){
  51.                     document.write(texto[1] + texto[7] + texto[8] +'<br>');
  52.                 }else{
  53.                     document.write(texto[0] + texto[6] + texto[8] +'<br>');
  54.                 }
  55.            }else{
  56.                document.write(texto[10] + texto[0] + texto[6] + texto[8]);
  57.            }
  58.         }
  59.     </script>
  60.    
  61.   </body>
  62. </html>
RAW Paste Data