Generate random numbers to guess the number size
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <style> *{ margin: 0; padding: 0; font-size: 30px; } input{ width: 500px; height: 50px; font-size: 30px; } button{ width: 80px; height: 50px; border: 0; text-align: center; line-height: 50px; background: darkblue; color: #fff; margin-left: 5px; } </style> <script src="angular/angular.js"></script> <script> var myapp=angular.module("myapp",[]); myapp.controller("myCtrl",function ($scope) { $scope.check=function () { console.log($scope.random); $scope.differ=$scope.guess-$scope.random; $scope.num++; }; $scope.reset=function () { $scope.differ=null; $scope.guess=null; $scope.num=0; $scope . random = Math . ceil ( Math . random ()* 10 ); }; $scope . reset (); }) </ script > </ head > < body ng-app= "myapp" ng-controller = "myCtrl" > < h2 > Please enter an integer from 1-10 </ h2 > < input type= "text" ng-model= "guess">< button ng-click= " check ()" > check </button> < button ng -click= " reset ()" > reset </button> < p ng -if= " diff > 0" > guess big < / p > < p ng-if= " diff <0" > Guess is small</p> < p ng -if= " diff == 0" >Guess right </p> < _ p > guessed < span ng-bind= " num " >< span > times in total </ p > </ body > </ html >