for (var counter = 1; counter <= 100; counter = counter + 1) {
if (counter % 3 == 0 || counter % 5 == 0) {
if (counter % 3 == 0 && counter % 5 == 0) {
console.log('FELDM');
} else {
if (counter % 3 == 0) {
console.log('FELD');
} else {
console.log('M');
}
}
} else {
console.log(counter);
}
}
for (var counter = 1; counter <= 100; counter = counter + 1) {
var message = "";
if (counter % 3 == 0) {
message = message + "FELD";
}
if (counter % 5 == 0) {
message = message + "M";
}
console.log(message || counter);
}
var texts = ['FELD', 'M'];
var numbers = [1, 2, texts[0], 4, texts[1], texts[0], 7, 8, texts[0],
texts[1], 11, texts[0], 13, 14, texts[0] + texts[1], 16, 17, texts[0],
19, texts[1], texts[0], 22, 23, texts[0], texts[1], 26, texts[0], 28,
29, texts[0] + texts[1], 31, 32, texts[0], 34, texts[1], texts[0], 37,
38, texts[0], texts[1], 41, texts[0], 43, 44, texts[0] + texts[1], 46,
47, texts[0], 49, texts[1], texts[0], 52, 53, texts[0], texts[1], 56,
texts[0], 58, 59, texts[0] + texts[1], 61, 62, texts[0], 64, texts[1],
texts[0], 67, 68, texts[0], texts[1], 71, texts[0], 73, 74, texts[0] + texts[1],
76, 77, texts[0], 79, texts[1], texts[0], 82, 83, texts[0], texts[1],
86, texts[0], 88, 89, texts[0] + texts[1], 91, 92, texts[0], 94, texts[1],
texts[0], 97, 98, texts[0], texts[1]]
for (var counter = 0; counter <= numbers.length; counter = counter + 1) {
console.log(numbers[counter]);
}
for (var i=1; i<=100; i+=1) {
if (i % 3 == 0 && i % 5 == 0) {
console.log("FELDM");
} else if (i % 3 == 0) {
console.log("FELD");
} else if (i % 5 == 0) {
console.log("M");
} else {
console.log(i);
}
};
console.log('Take this');
alert('Attention! We found a virus on your computer.');
confirm('Should we remove the virus, we found on your computer?');
prompt('What is the meaning of life?');
Math.min(23, 42, 3, 110);
> 3
var funktionsName = function(parameter1, parameter2, … parameterN) {
// Hier können wir mit dem Werten der paramter arbeiten.
};
var square = function(x) {
console.log(x * x);
};
Aufruf einer Funktion erfolgt druch funktionsName();
square(3);
> 9
var x = 'Jonathan Franzen';
var favouriteAuthor = function() {
var x = 'Philipp Roth';
console.log(x);
}
console.log(x);
favouriteAuthor();
> Jonathan Franzen
> Philipp Roth
Wir wollen mit dem Ergebnis der Funktion weiter arbeiten …
var square = function(x) {
return x * x;
};
var result = square(4);
console.log(characters); // ???
Besser noch:
for (var i=0; i