Javascript / HTML随机字符放在页面底部

时间:2017-05-24 06:31:32

标签: javascript html

Random Character example是指向我网页图片的链接。 我找不到>的位置生成页面底部的符号。我已经使用cmd f来搜索代码中的随机代码,似乎都没有放错位置。尽管如此,它并不是非常具有侵入性,我喜欢理解我的代码。

另外,我不明白为什么我的for循环没有激活。

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>The web site of matt9878</title>
    <!-- The style.css file allows you to change the look of your web pages.
         If you include the next line in all your web pages, they will all share the same look.
         This makes it easier to make new pages for your site. -->
    <link href="/style.css" rel="stylesheet" type="text/css" media="all">
  </head>
  <body>
    
    <div class="outputText">
      
      <!-- Equations assighment -->
      <p id="equation"> Equation assighment: <br/></p>
      
      <!-- Counting Coins assighment -->
      <p id="combinations"> Coin combo assighment: <br/></p>
      
      <!-- Timely Mesasurements assighment -->
      <p id= "circumference"> Timely Mesasurements assighment: <br/></p>
         
      <!-- Blackjack assighment -->   
      <p id="blackjackTotal"> Blackjack assighment: <br/></p>
      
      <!-- Prime Time Assighment -->  
      <p id="primeTime"> Prime Time assighment: <br/></p>
      
      
    </div>  
       
    <!-- Greetings assignment -->
    <script>
      window.alert("Hola, Como esta?");
    </script>
    
    <!--Equations assighment-->
    <script>
      
      for(i = 0; i < 4; i++)
      {   
        var x = Math.round(Math.random() * 1500);
        var y = Math.round(Math.random() * 1500);
        
        document.getElementById("equation").innerHTML += x + " + " + y + " = " + (x + y) + "<br/>";
      }
      
      //*seriesOfEquations();
    </script>
    
    <!-- Counting Coins assighment -->
    <script>
      var value = 175;
      
      var penny = 1;
      var nickel = 5;
      var dime = 10;
      var quarter = 25;
      
      document.getElementById("combinations").innerHTML += (value / penny) + "(" + penny + ")" + " = " + value + "<br/>";
      document.getElementById("combinations").innerHTML += (value / nickel) + "(" + nickel + ")" + " = " + value + "<br/>";
      document.getElementById("combinations").innerHTML += Math.floor(value / dime) + "(" + dime + ")" + 
        " + " + nickel + " = " + value + "<br/>";
      document.getElementById("combinations").innerHTML += (value / quarter) + "(" + quarter + ")" + " = " + value + "<br/>";
      
    </script>
    
    <!-- Timely Mesasurements assighment -->
    <script>
      var date = new Date();
      var rad = date.getHours();
      
      document.getElementById("circumference").innerHTML += (2 * Math.PI * rad).toFixed(3) + "<br/>";
    </script>
    
    <!-- Blackjack assighment -->>
    <script>
      //Card dealing
      var cardOne = (Math.ceil(Math.random() * 10 ) + 1);
      var cardTwo = (Math.ceil(Math.random() * 10 ) + 1);
      var combined = cardOne + cardTwo;
      
      var cardValues = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
      
      //Ace checking
      if (cardOne == 11 && combined > 21) {
        cardOne = 1;
        combined = cardOne + cardTwo;
      }
      else if (cardTwo == 11 && combined > 21) {
        cardTwo = 1;
        combined = cardOne + cardTwo;
      }  
    
      //Dealer hit sequence
      if (combined < 17) {
      
        document.getElementById("blackjackTotal").innerHTML += "The dealer is hitting thier current total of " + combined + "<br/>";
        
        cardOne = (Math.ceil(Math.random() * 10 ) + 1);
        
        //Ace checking
        if (cardOne == 11 && (combined + cardOne) > 21) {
          cardOne = 1;
          combined = combined + cardOne;
        }
        else {
          combined = combined + cardOne;
        }
      }
   
      //Blackjack
      if (combined == 21) {    
        document.getElementById("blackjackTotal").innerHTML += "Blackjack!!!!" + "<br/>";   
      }
      
      //Dealer bust 
      else if (combined > 21) {
        document.getElementById("blackjackTotal").innerHTML += "The dealer has gone bust with a total of " + combined + "." + "<br/>";
      }
      
      //Dealer total ancouncement
      else{
        document.getElementById("blackjackTotal").innerHTML += "The dealer's total is " + combined + "." + "<br/>";
      }
      
    </script>
    
    <!--  Prime time assighment -->
    <script> 
      var numOne = Number(prompt("Please enter the first whole number to begin the range you'd like to explore."));
      var numTwo = Number(prompt("Enter the second whole number to conclude the range you'd like to explore. Hint: Second choice > first."));
      
      window.alert(numOne + ", " + numTwo);
      
      if (numOne < numTwo && (numOne.isInteger() && numTwo.isInteger())) {
        for(; numOne <= numTwo; numOne++) {
          document.getElementById("primeTime").innerHTML += numOne + ", " + numTwo + "<br/>";
        }         
      }
      else {
        window.alert("Please reload the webpage and try again. Error code: User error.");
      } 
    </script>
    
  </body>
</html>

2 个答案:

答案 0 :(得分:0)

就在卡片交易代码之上,还有额外的“&gt;”在评论的二十一点任务中。希望它会有所帮助

答案 1 :(得分:0)

在第77行,评论中有一个额外的 /** * Marks all controls in a form group as touched * @param formGroup - The form group to touch */ private markFormGroupTouched(formGroup: FormGroup) { (<any>Object).values(formGroup.controls).forEach(control => { control.markAsTouched(); if (control.controls) { this.markFormGroupTouched(control); } }); }

>

运行

&GT;

修正:

<!-- Blackjack assighment -->>