You must hand in by using git
bitbucket.org,
gitlab.com, or
github.com,
git push your local repo to the above remote repo.
node_modules/
.gitignore file.
Send a mail to <nmla@iba.dk> with:
handin <subjectname>'
in the subject line of your mail
The following assignments/exercises are meant to train
programmatic thinking and coding essential for coding
in any programming language. Here we use JavaScript. You may
have various degrees of coding experience from earlier
studies. From that you may be familiar with if's
or various loop constructs. Today's assignments
must be solved without any of those.
The techniques used in the examples of today's chapter
should be sufficient.
We will of course get to if's and loops very soon.
Write a program into a file called js15.js.
The program must accept input of a number from the user. Assume the number is the temperature in Fahrenheit. Your program must convert the temperature to Celsius and print it on the console.
The conversion formula is c = 5/9(f-32)
where c is the result in Celsius, and f
is the temperature in Fahrenheit.
Write a program into a file called js201.js.
The program must accept input of a number from the user. Assume the number is a year. Make JavaScript write on the console true or false as to whether the year is a leap year or not. If you don't know what a leap year is, Google it.
Write another program into a file called js202.js.
The program must accept input of a number from the user. Assume the number is a CPR number (a danish social security number). Make JavaScript write on the console true or false as to whether the person holding the number is a woman.
In todays lesson, re Example 2.7, there was an example of letting JavaScript print the truth table for a negation on the console.
js25c.js
for printing the truth table for the conjunction.
js25d.js with the code for printing the truth
table for the disjunction.
You will have noticed that a conjunction/disjunction of two questions have four possible outcomes, each condition may be true or false. Two conditions, 2 x 2 possible outcomes.
Three conditions that could each result in true or false thus gives you 2 x 2 x 2 = 8 possible outcomes.
js25c3.js
for printing the truth table for a conjunction of 3
conditions: var1, var2, and
var3.
js25d3.js with the code for printing the truth
table for a disjunction with three conditions.
For the latter two, it may be very helpful to visualize by drawing them on paper first.