Posts

REST PARAMETERS AND THE SPREAD OPERATOR

It can be very useful for a function to accept any number of arguments. For example, Math.max computes the maximum of all arguments it is given But how can we write such a function  well the answer is rest parameter look at this code: function   max (... numbers ) {      let   result  = - Infinity ;      for  ( let   number   of   numbers ) {           if  ( number  >  result )  result  =  number ;     }      return   result ; } console . log ( max ( 4 ,  1 ,  9 , - 2 )); // → 9 in the above example the number argument contains all the value as an array (i,e. [4,1,9,-2]) , and it is our rest parameter . a rest parameter takes extra arguments and hold them in an array.And the triple dot(...) sign is called our spread operator . for example: function   restP...
test your typing speed here is the source code..... <!DOCTYPE html> <html> <head>  <title> test your typing speed </title> <style> *{ margin:0px; padding:0px; box-sizing: border-box; } body{ background-color:#d0bdf4; } #container{ position:fixed; bottom:5%; /*width:80%;*/ margin-left:10%; background: #ace600; } #display{ position:absolute; top:10%; background-color:red; font-size:50px; left:20%; width:60%; box-sizing:border-box; height:100px; padding:20px; text-align:center; display:none; } .key{ background-color:#737373; color:white; font-size:60px; padding:5px 15px; margin:5px; border-radius:20px; } .upper{ margin-top:10px; } .middle{ margin: 20px 40px; } .lower{ margin: 20px 80px; } .text{ display: inline; font-size:35px; } .header{ width:100%; height:40px; background-color:#ace600; } #time{ float:right; font-size: 30px; margin-right:50px; } </style> <...

calculator using javascript

Image
simple calculator using html, css and javascript Hello frends welcome to my blog. Here is a simple blog on how to create calculator using html,css and javascript. The calculator works upto five clicks and if you will click after five clicks the calculator would not work properly. here is its image.. And here is its source code <! DOCTYPE   html > < html   lang = "en" > < head >    < meta   charset = "UTF-8" >    < meta   name = "viewport"   content = "width=device-width, initial-scale=1.0" >    < title > Calculator </ title >    < style >      body {        background : #00004d ;     }      .container {        overflow :  hidden ;        display : flex ;        max-width : 465px ;  ...

tic tac toe game

Image
hello frends welcome to my blog. here is a code of the simple game tic tac toe. I hope you had played it before if you will find any error in this code then please comment below. And here is its code. I hope you will like this. <! DOCTYPE   html > < html   lang = "en" > < head >      < meta   charset = "UTF-8" >      < meta   name = "viewport"   content = "width=device-width, initial-scale=1.0" >      < title >  Tic Tac toe  </ title >      < style >          table   tr   td:hover {              box-shadow :  0   4px   8px   0   black ,  0   6px   20px   0   black ;         }       ...