- Create a program that outputs all leap years between 1900 and 2200
- Here's a quote from the german Wikipedia explaining the rules:
- Die durch 4 ganzzahlig teilbaren Jahre sind, abgesehen von den folgenden Ausnahmen, Schaltjahre.
- Säkularjahre, also die Jahre, die ein Jahrhundert abschließen (z. B. 1800, 1900, 2100 und 2200), sind, abgesehen von der folgenden Ausnahme, keine Schaltjahre.
- Die durch 400 ganzzahlig teilbaren Säkularjahre, zum Beispiel das Jahr 2000, sind jedoch Schaltjahre.
- You can check the Wikipedia article as well for a full list to check your result against.
- Create an array with some random data (think of something fun yourself, could be strings, could be numbers)
- Create a single variable that contains something that may or may not be in the array
- Write some code that finds out if the thing in the variable is also in the array
let haystack = [1,2,3,4,5];
let needle = 7;
let found = false
// code for finding the needle in the haystack
// for(...) {
// ...
// }
console.log("Found?", found);
Given the following array:
let names = ["Anne", "Dick", "George", "Ju", "Timmy"];
Find and output the longest name in the list.
Hint: Strings in many ways behave like Arrays and one of that way is that strings also have a .length
property we can use:
let name = "Jan"
name.length // => 3