0

I think my solution is right I mean algorithm but this isn't rendered by node.js my console just stop (My Goal: want to calculate positive whole numbers root square without using javascript own functions)


THIS IS MY CODE:

   function squareRoot(number){
 
    if(number<0 ||  false === Number.isInteger(number)){
      return 'PLEASE ENTER POSITVE WHOLE NUMBER!!!'
    }else{
        let container=0;
        for(let root=0; container<number;root=root+0.1 ){
          if(number===root*root){
            return root;
          }else{}
             }
         }
         };
      console.log(squareRoot(9));
  • [Improving algorithm for finding square roots of perfect squares without Math.sqrt](https://stackoverflow.com/questions/35855799/javascript-improving-algorithm-for-finding-square-roots-of-perfect-squares-wit) – alexP Jan 18 '21 at 07:36
  • Floating point numbers don't work like you would normally expect. This isn't a "Javascript" thing, this is true EVERY programming language that uses floating point. While I did vote to close this question, the linked answer goes into a lot of detail. – Jeremy J Starcher Jan 18 '21 at 07:36

0 Answers0