Assignments JS.Funcs

Handing In Assignments

You must hand in by using git

Hand In by git

  • Create an empty repo on bitbucket.org, gitlab.com, or github.com,
  • git push your local repo to the above remote repo.
  • For node assignments please put the line(s)

    node_modules/

    into your .gitignore file.

Send a mail to with:

  • The word 'handin <subjectname>' in the subject line of your mail
  • The url of your repo(s).

Assignment JS.Funcs.0

Write three functions:

  • addVat(a), that returns amount including vat given an amount as input.
  • subVat(a), that returns amount excluding vat given an amount as input.
  • calcVat(a), that returns the vat from the given amount.

Use the Danish vat of 25.0%.

Hand in as a file called jsFuncs0.js

Assignment JS.Funcs.1

Write three functions:

  • Write a function first(s), that returns the first character of the string s.
  • Write a function last(s), that returns the last character of the string s.
  • Write a function middle(s), that returns whatever is between the first and the last character of the string s.

Hint: Take a look a the string functions in your MDN reference, especially the substr function.

Hand in as one file called jsTextUtils.js

Assignment JS.Funcs.2

In todays lesson, I gave you play() that could flip a coin. We have, in the lesson about conditionals, worked with throwing a die. On principle this there is only one tiny difference between the two.

Now, I want you to identify this difference, and then alter play, so that it accomodates coin flipping, die throwing, turning a spindle with any number of sides, and even a roulette.

Place the function in myFuncLib.js.

Assignment JS.Funcs.3

Write two functions C2F(c), and F2C(f) the first converts celsius temperatures to Fahrenheit, and the other Fahrenheit to Celsius.

Place the functions in myFuncLib.js.