Sort by

recency

|

236 Discussions

|

  • + 0 comments
    function sides(literals, ...expressions) {
        let A = expressions[0];
        let P = expressions[1];
    
        let s1 = (P+(Math.sqrt((P*P)-16*A)))/4;
        let s2 = (P-(Math.sqrt((P*P)-16*A)))/4;
    
        return [s1,s2].sort();
    

    }

  • + 1 comment

    After finishing this problem I reached a conclusion: This has absolutely nothing to do with template literals!

  • + 0 comments
    function sides(literals, ...expressions) {
      const [A,P] = [...expressions]
      let s1 = (P+Math.sqrt(P**2 - 16 *A))/4
      let s2 = (P-Math.sqrt(P**2 - 16 *A))/4
      
      return [s1,s2].sort()
    }
    
  • + 0 comments
    function sides(literals, ...expressions) {
        let square=expressions[1]*expressions[1],air=16*expressions[0];
        let s1=(expressions[1]+Math.sqrt(square-air))/4;
        let s2=(expressions[1]-Math.sqrt(square-air))/4;
        
        let s=[s1,s2];
        s=s.sort();
        return s;
    }
    
  • + 0 comments

    Javascript one-step solution:

    const sides=(literals, ...e)=>[
        (e[1]-(e[1]**2-16*e[0])**0.5)/4,
        (e[1]+(e[1]**2-16*e[0])**0.5)/4
    ];