karkhikavari

  • Home
  • Features
    • Multi DropDown
      • DropDown 1
      • DropDown 2
      • DropDown 3
    • ShortCodes
    • Sitemap
    • Error Page
  • Seo Services
  • Documentation
  • Download This Template
  • Home
  • Features►
    • Multi DropDown►
      • DropDown 1
      • DropDown 2
      • DropDown 3
    • ShortCodes
    • Sitemap
    • Error Page
  • Seo Services
  • Documentation
  • Download This Template

javaScript - FUNCTIONS - Return II

Mei 22, 2019 coding, javascript
FUNCTIONS

Return II

In the last exercise, we pointed out that using return makes programs more maintainable and flexible, but how exactly?
When functions return their value, we can use them together and inside one another. If our calculator needed to have a Celsius to Fahrenheit operation, we could write it with two functions like so:
const multiplyByNineFifths = (celsius) => { return celsius * (9/5); }; const getFahrenheit = (celsius) => { return multiplyByNineFifths(celsius) + 32; }; console.log('The temperature is ' + getFahrenheit(15) + '°F'); // Output: The temperature is 59°F
Take a look at the getFahrenheit() function. Inside of its block, we called multiplyByNineFifths() and passed it the degrees in celsius. The multiplyByNineFifths() function multiplied the celsius by (9/5). Then it returned its value so the getFahrenheit() function could continue on to add 32 to it.
Finally, on the last line, we interpolated the function call within a console.log()statement. This works because getFahrenheit() returns its value.
We can use functions to section off small bits of logic or tasks, then use them when we need to. Writing functions can help take large and difficult problems and break them into small and manageable problems.
1.
It's your job to calculate two more numbers for each order:
  • A sales tax of 6% needs to be calculated for every full order. This should be based on the subtotal.
  • The total, which is the subtotal plus tax, should also be computed.
Let's start with calculating the tax. Under the getSubTotal()function, create a function expression using the variable constnamed getTax. This function will take one parameter named itemCount.
Stuck? Get a hint
2.
Inside the getTax()function, call your getSubTotal() function and pass it the argument itemCount to get the subtotal, and then multiply the returned value by 6% (0.06). Make sure to return the result of this operation.
Stuck? Get a hint
Share This:
Facebook Twitter Google+ Pinterest Linkedin Whatsapp
javascript
di Mei 22, 2019
Kirimkan Ini lewat EmailBlogThis!Bagikan ke XBerbagi ke FacebookBagikan ke Pinterest
Label: coding, javascript

Tidak ada komentar:

Posting Komentar

Posting Lebih Baru Posting Lama Beranda
Langganan: Posting Komentar (Atom)

Popular

  • JavaScript - FUNCTIONS - Parameters
    FUNCTIONS Parameters Sejauh ini fungsi kami belum membutuhkan masukan apa pun. Kami juga dapat menulis fungsi yang menerima data. K...
  • 3.Step How To Be programmer
      Cara Menjadi Seorang Programer you ccan visit this website to learn programming =  https://www.codecademy.com/courses/introduction-to-java...
  • JavaScript : CONTROL FLOW : Ternary Operator
    CONTROL FLOW Ternary Operator Dalam latihan sebelumnya, kami belajar menulis singkat jika ada pernyataan  if / else    if / else  untuk ...
  • React : ReactDOM.render () I
    ReactDOM.render () I Mari kita periksa kode yang baru saja Anda tulis. Mulai di before.js, di jalur 5, terus ke kiri. Anda dapat melihat...
  • JavaScript : FUNCTIONS : Return
    FUNCTIONS Return Menggunakan  console.log()  sebagai hasil dari sebuah fungsi bukanlah tidak baik digunakan dalam fungsi. Tujuan su...

Tags

About coding Game javascript phaser program python React
Created By Karkhi Kavari