JavaScript percentage calculation functions [on hold]Custom JavaScript function queueStructure JavaScript...

What do you call the infoboxes with text and sometimes images on the side of a page we find in textbooks?

Can a malicious addon access internet history and such in chrome/firefox?

Lightning Web Component - do I need to track changes for every single input field in a form

Proof of Lemma: Every integer can be written as a product of primes

Was the picture area of a CRT a parallelogram (instead of a true rectangle)?

Invariance of results when scaling explanatory variables in logistic regression, is there a proof?

What was required to accept "troll"?

How can a jailer prevent the Forge Cleric's Artisan's Blessing from being used?

Why does this part of the Space Shuttle launch pad seem to be floating in air?

How will losing mobility of one hand affect my career as a programmer?

Teaching indefinite integrals that require special-casing

Word describing multiple paths to the same abstract outcome

Is there enough fresh water in the world to eradicate the drinking water crisis?

Stereotypical names

What will be the benefits of Brexit?

A workplace installs custom certificates on personal devices, can this be used to decrypt HTTPS traffic?

Is exact Kanji stroke length important?

What to do when my ideas aren't chosen, when I strongly disagree with the chosen solution?

How to prevent YouTube from showing already watched videos?

Partial sums of primes

The One-Electron Universe postulate is true - what simple change can I make to change the whole universe?

My boss asked me to take a one-day class, then signs it up as a day off

Why are on-board computers allowed to change controls without notifying the pilots?

Who must act to prevent Brexit on March 29th?



JavaScript percentage calculation functions [on hold]


Custom JavaScript function queueStructure JavaScript codeCDN Fallback “library”Functional organisation of JavaScript functionsMortgage calculator in JavaScriptAnimated SVG pie chart with custom propertiesTo-do app, as one monster function and as several smaller functionsShuntyard Javascript Calculator with unit testsCondensing a TableJavaScript interest rate calculator













0












$begingroup$


I am building a calculator and I'm aware of what these functions do.



What I basically want feedback on is: Do I need to comment this or is there sufficient information to ascertain its purpose:



function percentOfValue(percentage, of) {
return (percentage / 100) * of;
}

function whatPercentOfValue(small, large) {
return (small / large) * 100
}









share|improve this question









New contributor




Chris is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$



put on hold as off-topic by πάντα ῥεῖ, Sᴀᴍ Onᴇᴌᴀ, yuri, Gerrit0, Raystafarian 1 hour ago


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Lacks concrete context: Code Review requires concrete code from a project, with sufficient context for reviewers to understand how that code is used. Pseudocode, stub code, hypothetical code, obfuscated code, and generic best practices are outside the scope of this site." – πάντα ῥεῖ, Sᴀᴍ Onᴇᴌᴀ, yuri, Gerrit0, Raystafarian

If this question can be reworded to fit the rules in the help center, please edit the question.





















    0












    $begingroup$


    I am building a calculator and I'm aware of what these functions do.



    What I basically want feedback on is: Do I need to comment this or is there sufficient information to ascertain its purpose:



    function percentOfValue(percentage, of) {
    return (percentage / 100) * of;
    }

    function whatPercentOfValue(small, large) {
    return (small / large) * 100
    }









    share|improve this question









    New contributor




    Chris is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.







    $endgroup$



    put on hold as off-topic by πάντα ῥεῖ, Sᴀᴍ Onᴇᴌᴀ, yuri, Gerrit0, Raystafarian 1 hour ago


    This question appears to be off-topic. The users who voted to close gave this specific reason:


    • "Lacks concrete context: Code Review requires concrete code from a project, with sufficient context for reviewers to understand how that code is used. Pseudocode, stub code, hypothetical code, obfuscated code, and generic best practices are outside the scope of this site." – πάντα ῥεῖ, Sᴀᴍ Onᴇᴌᴀ, yuri, Gerrit0, Raystafarian

    If this question can be reworded to fit the rules in the help center, please edit the question.



















      0












      0








      0





      $begingroup$


      I am building a calculator and I'm aware of what these functions do.



      What I basically want feedback on is: Do I need to comment this or is there sufficient information to ascertain its purpose:



      function percentOfValue(percentage, of) {
      return (percentage / 100) * of;
      }

      function whatPercentOfValue(small, large) {
      return (small / large) * 100
      }









      share|improve this question









      New contributor




      Chris is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.







      $endgroup$




      I am building a calculator and I'm aware of what these functions do.



      What I basically want feedback on is: Do I need to comment this or is there sufficient information to ascertain its purpose:



      function percentOfValue(percentage, of) {
      return (percentage / 100) * of;
      }

      function whatPercentOfValue(small, large) {
      return (small / large) * 100
      }






      javascript






      share|improve this question









      New contributor




      Chris is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question









      New contributor




      Chris is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question








      edited yesterday









      200_success

      130k17155419




      130k17155419






      New contributor




      Chris is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked yesterday









      ChrisChris

      1064




      1064




      New contributor




      Chris is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Chris is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Chris is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




      put on hold as off-topic by πάντα ῥεῖ, Sᴀᴍ Onᴇᴌᴀ, yuri, Gerrit0, Raystafarian 1 hour ago


      This question appears to be off-topic. The users who voted to close gave this specific reason:


      • "Lacks concrete context: Code Review requires concrete code from a project, with sufficient context for reviewers to understand how that code is used. Pseudocode, stub code, hypothetical code, obfuscated code, and generic best practices are outside the scope of this site." – πάντα ῥεῖ, Sᴀᴍ Onᴇᴌᴀ, yuri, Gerrit0, Raystafarian

      If this question can be reworded to fit the rules in the help center, please edit the question.







      put on hold as off-topic by πάντα ῥεῖ, Sᴀᴍ Onᴇᴌᴀ, yuri, Gerrit0, Raystafarian 1 hour ago


      This question appears to be off-topic. The users who voted to close gave this specific reason:


      • "Lacks concrete context: Code Review requires concrete code from a project, with sufficient context for reviewers to understand how that code is used. Pseudocode, stub code, hypothetical code, obfuscated code, and generic best practices are outside the scope of this site." – πάντα ῥεῖ, Sᴀᴍ Onᴇᴌᴀ, yuri, Gerrit0, Raystafarian

      If this question can be reworded to fit the rules in the help center, please edit the question.






















          1 Answer
          1






          active

          oldest

          votes


















          1












          $begingroup$

          Code level comments usually lose their context if not properly maintained. Using self descriptive variable names is a good choice. Appreciate your efforts in keeping the code highly readable.




          • First method, is trying to get the Percentage value, I would update the method definition to getPercentOfValue(from, percentage).


          • Second method, is trying to calculate percent rate, I would update the method definition to getPercentRate(newValue, originalValue) to follow the terminology in formula.







          share|improve this answer








          New contributor




          brightDot is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.






          $endgroup$













          • $begingroup$
            A couple of small changes that give absolute clarity, thank you.
            $endgroup$
            – Chris
            19 hours ago










          • $begingroup$
            I'd suggest not to use the prefix get as these are not "getters" as customarily used in Java. Instead use, for example, calc(ulate).
            $endgroup$
            – RoToRa
            17 hours ago










          • $begingroup$
            Thankyou @RoToRa that does make sense if it would change the perceived use. Other than that change, I think its fairly self explanitory, to be fair it may never see the light of day after I close up this development session but you never know so i would rather not be beating myself up down the road for not making commenting it or making it readable. I am of the principle that a comment should only be used when there is no way to make it obvious. I hope ive managed that here.
            $endgroup$
            – Chris
            4 hours ago




















          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1












          $begingroup$

          Code level comments usually lose their context if not properly maintained. Using self descriptive variable names is a good choice. Appreciate your efforts in keeping the code highly readable.




          • First method, is trying to get the Percentage value, I would update the method definition to getPercentOfValue(from, percentage).


          • Second method, is trying to calculate percent rate, I would update the method definition to getPercentRate(newValue, originalValue) to follow the terminology in formula.







          share|improve this answer








          New contributor




          brightDot is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.






          $endgroup$













          • $begingroup$
            A couple of small changes that give absolute clarity, thank you.
            $endgroup$
            – Chris
            19 hours ago










          • $begingroup$
            I'd suggest not to use the prefix get as these are not "getters" as customarily used in Java. Instead use, for example, calc(ulate).
            $endgroup$
            – RoToRa
            17 hours ago










          • $begingroup$
            Thankyou @RoToRa that does make sense if it would change the perceived use. Other than that change, I think its fairly self explanitory, to be fair it may never see the light of day after I close up this development session but you never know so i would rather not be beating myself up down the road for not making commenting it or making it readable. I am of the principle that a comment should only be used when there is no way to make it obvious. I hope ive managed that here.
            $endgroup$
            – Chris
            4 hours ago


















          1












          $begingroup$

          Code level comments usually lose their context if not properly maintained. Using self descriptive variable names is a good choice. Appreciate your efforts in keeping the code highly readable.




          • First method, is trying to get the Percentage value, I would update the method definition to getPercentOfValue(from, percentage).


          • Second method, is trying to calculate percent rate, I would update the method definition to getPercentRate(newValue, originalValue) to follow the terminology in formula.







          share|improve this answer








          New contributor




          brightDot is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.






          $endgroup$













          • $begingroup$
            A couple of small changes that give absolute clarity, thank you.
            $endgroup$
            – Chris
            19 hours ago










          • $begingroup$
            I'd suggest not to use the prefix get as these are not "getters" as customarily used in Java. Instead use, for example, calc(ulate).
            $endgroup$
            – RoToRa
            17 hours ago










          • $begingroup$
            Thankyou @RoToRa that does make sense if it would change the perceived use. Other than that change, I think its fairly self explanitory, to be fair it may never see the light of day after I close up this development session but you never know so i would rather not be beating myself up down the road for not making commenting it or making it readable. I am of the principle that a comment should only be used when there is no way to make it obvious. I hope ive managed that here.
            $endgroup$
            – Chris
            4 hours ago
















          1












          1








          1





          $begingroup$

          Code level comments usually lose their context if not properly maintained. Using self descriptive variable names is a good choice. Appreciate your efforts in keeping the code highly readable.




          • First method, is trying to get the Percentage value, I would update the method definition to getPercentOfValue(from, percentage).


          • Second method, is trying to calculate percent rate, I would update the method definition to getPercentRate(newValue, originalValue) to follow the terminology in formula.







          share|improve this answer








          New contributor




          brightDot is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.






          $endgroup$



          Code level comments usually lose their context if not properly maintained. Using self descriptive variable names is a good choice. Appreciate your efforts in keeping the code highly readable.




          • First method, is trying to get the Percentage value, I would update the method definition to getPercentOfValue(from, percentage).


          • Second method, is trying to calculate percent rate, I would update the method definition to getPercentRate(newValue, originalValue) to follow the terminology in formula.








          share|improve this answer








          New contributor




          brightDot is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.









          share|improve this answer



          share|improve this answer






          New contributor




          brightDot is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.









          answered yesterday









          brightDotbrightDot

          322




          322




          New contributor




          brightDot is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.





          New contributor





          brightDot is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.






          brightDot is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.












          • $begingroup$
            A couple of small changes that give absolute clarity, thank you.
            $endgroup$
            – Chris
            19 hours ago










          • $begingroup$
            I'd suggest not to use the prefix get as these are not "getters" as customarily used in Java. Instead use, for example, calc(ulate).
            $endgroup$
            – RoToRa
            17 hours ago










          • $begingroup$
            Thankyou @RoToRa that does make sense if it would change the perceived use. Other than that change, I think its fairly self explanitory, to be fair it may never see the light of day after I close up this development session but you never know so i would rather not be beating myself up down the road for not making commenting it or making it readable. I am of the principle that a comment should only be used when there is no way to make it obvious. I hope ive managed that here.
            $endgroup$
            – Chris
            4 hours ago




















          • $begingroup$
            A couple of small changes that give absolute clarity, thank you.
            $endgroup$
            – Chris
            19 hours ago










          • $begingroup$
            I'd suggest not to use the prefix get as these are not "getters" as customarily used in Java. Instead use, for example, calc(ulate).
            $endgroup$
            – RoToRa
            17 hours ago










          • $begingroup$
            Thankyou @RoToRa that does make sense if it would change the perceived use. Other than that change, I think its fairly self explanitory, to be fair it may never see the light of day after I close up this development session but you never know so i would rather not be beating myself up down the road for not making commenting it or making it readable. I am of the principle that a comment should only be used when there is no way to make it obvious. I hope ive managed that here.
            $endgroup$
            – Chris
            4 hours ago


















          $begingroup$
          A couple of small changes that give absolute clarity, thank you.
          $endgroup$
          – Chris
          19 hours ago




          $begingroup$
          A couple of small changes that give absolute clarity, thank you.
          $endgroup$
          – Chris
          19 hours ago












          $begingroup$
          I'd suggest not to use the prefix get as these are not "getters" as customarily used in Java. Instead use, for example, calc(ulate).
          $endgroup$
          – RoToRa
          17 hours ago




          $begingroup$
          I'd suggest not to use the prefix get as these are not "getters" as customarily used in Java. Instead use, for example, calc(ulate).
          $endgroup$
          – RoToRa
          17 hours ago












          $begingroup$
          Thankyou @RoToRa that does make sense if it would change the perceived use. Other than that change, I think its fairly self explanitory, to be fair it may never see the light of day after I close up this development session but you never know so i would rather not be beating myself up down the road for not making commenting it or making it readable. I am of the principle that a comment should only be used when there is no way to make it obvious. I hope ive managed that here.
          $endgroup$
          – Chris
          4 hours ago






          $begingroup$
          Thankyou @RoToRa that does make sense if it would change the perceived use. Other than that change, I think its fairly self explanitory, to be fair it may never see the light of day after I close up this development session but you never know so i would rather not be beating myself up down the road for not making commenting it or making it readable. I am of the principle that a comment should only be used when there is no way to make it obvious. I hope ive managed that here.
          $endgroup$
          – Chris
          4 hours ago





          Popular posts from this blog

          is 'sed' thread safeWhat should someone know about using Python scripts in the shell?Nexenta bash script uses...

          How do i solve the “ No module named 'mlxtend' ” issue on Jupyter?

          Pilgersdorf Inhaltsverzeichnis Geografie | Geschichte | Bevölkerungsentwicklung | Politik | Kultur...