Manuel

Lösungen zum "Test" :

<html>
<head>
<title>Test</title>
<script type="text/javascript">
 
var teststring = "Karl der Grosse lebte vor langer Zeit.";
var Titel = "Die Probe";
document.write("<br>" +Titel.fontsize(6));
 
//Aufgabe 1: klein / GROSS
 
document.write("<br><br> Aufgabe 1: <br> a. " +teststring.toLowerCase());
document.write("<br> b. " +teststring.toUpperCase());
 
//Aufgabe 4 : String Rückwäts
 
var ianzahl = teststring.length-1;
var Alles = "Teststring rückwärts: ";
var Ruckwarts = "";
 
   for (var i=ianzahl; i>0; i--) {
    Ruckwarts=teststring.charAt(i);
    Alles=Alles.concat(Ruckwarts);
    }
var Ruckwarts = teststring.charAt(0);
var Alles = Alles.concat(Ruckwarts);
 
document.write("<br><br> Aufgabe 4: <br>" +Alles);
 
// Aufgabe 5: Zahlen 1 bis 9
 
document.write("<br><br> Aufgabe 5:");
 
   for (var i=1; i<10; i++) {
    document.write("<br> i = " +i);
    }
 
//Aufgabe 6: James Bond
 
var James = "James ";
var Bond = "Bond";
 
document.write("<br><br> Aufgabe 6: <br>" +James.concat(Bond));
 
//Aufgabe 7: Integerzahl
var Sieben = 7;
 
document.write("00" +Sieben);
 
//Aufgabe 8: james Bond 00 i
 
var Name ="James Bond ";
var Zahl ="";
 
for (var i=1; i<10; i++) {
 
}
 
</script>
</head>
<body>
</body></html>

Lösung Aufgabe 2: ersetze alle " " (Leerschlag) durch "@@@"

document.write("<br> <br>   Aufgabe 2: " +teststring.replace(/ /g, "@@@"));

Lösung Aufgabe 3: gib den Teststring nur mit Kleinbuchstaben oder Grossbuchstaben aus

document.write("<br> <br>   Aufgabe 3.1: " +teststring.toLowerCase());
 
document.write("<br> <br>   Aufgabe 3.2: " +teststring.toUpperCase());

Lösung Aufgabe 4: Welcher Buchstabe steht an der 3, 5, 45 Position? Welcher an der ersten-letzten Position?

document.write("<br> <br>   Aufgabe 4.1: " +teststring.slice(2,3) +teststring.slice(4,5) +teststring.slice(44,45));

Lösung Aufgabe 5: Bestimme die Anzahl der Wörter! Welches ist das 13. Wort?

var Woerter = teststring.split(" "); 
document.write("<br><br>   Aufgabe 5: Dieser String hat " + Woerter.length + " Woerter");
document.write("<br>   Das 13. Wort des Strings ist '" +Woerter[12] +"'");
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.