Thursday, May 26, 2022

Js - that was hard but is completely

 And working, the 'test your skills-4-strings',

here solved wasn't in no place an function to convert but I fix it and only here you see in first hand how to solve this without the .template() THAT DOESN'T EXISTS, and I do it without a function and more I realize that after replacing *, I don't need know the place for the second *, because if replaced doesn't exits anymore so you only need to say look for * and will fire the second, and you say look for the * and will fire the third, Amen.

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8"/>
    <title>Strings: Task 4</title>
    <style>
      p {
        color: purple;
        margin: 0.5em 0;
      }

      * {
        box-sizing: border-box;
      }
    </style>
    <link rel="stylesheet" href="../styles.css" />
  </head>

  <body>

    <section class="preview">



    </section>

  </body>
  <script>
    const theorem = 'Pythagorean theorem';

    const a = 5;
    const b = 8;
   
    a
    const myString = 'Using *, we can work out that that if the two shortest sides of a right-angled triangle have lengths of * and *, the length of the hypotenuse is *.';
    alert(11);
   
    let string1 = `future`;
    string1 = string1.replace('future',myString);
    string1 = string1.replace('*',`${theorem}`);
    string1 = string1.replace('*',`${a}`);
    string1 = string1.replace('*',`${b}`);
    string1 = string1.replace('*',Math.sqrt(a*a+b*b).toFixed(3));
   
    alert(string1);
   
   
 

    // Don't edit the code below here!

    const section = document.querySelector('section');

    const para1 = document.createElement('p');
    para1.textContent = string1;//myString;
    section.appendChild(para1);
  </script>

</html>

Rute Bezerra de Menezes Gondim




No comments:

Post a Comment