<!-- oefening 1 --> <!DOCTYPE html> <html lang="nl"> <head> <title>Oefening 1</title> </head> <body> <script type="text/javascript"> var a = 12.345; document.write(a); document.write('<BR>'); document.write('Decimalen: ' + a.toFixed(2)); document.write('<BR>'); document.write('Lengte: ' + a.toPrecision(4)); </script> </body> </html>
Download hier het bestand.
<!-- oefening 2 --> <!DOCTYPE html> <html lang="nl"> <head> <title>Oefening 2</title> </head> <body> <script type="text/javascript"> var a = 'Hello World'; document.write(a.toLowerCase()); document.write('<BR>'); document.write(a.toUpperCase()); </script> </body> </html>
Download hier het bestand.
<!-- oefening 3 --> <!DOCTYPE html> <html lang="nl"> <head> <title>Oefening 3</title> </head> <body> <script type="text/javascript"> var a = prompt("Vul het 1e getal in"); var b = prompt("Vul het 2e getal in"); document.write(a); document.write('+'); document.write(b); document.write('='); document.write(parseInt(a) + parseInt(b)); </script> </body> </html>
Download hier het bestand.
<!-- oefening 4 --> <!DOCTYPE html> <html lang="nl"> <head> <title>Oefening 4</title> </head> <body> <script type="text/javascript"> var a = 'Hello World'; document.write(a); document.write('<BR>'); document.write('Lengte: ' + a.length); document.write('<BR>'); document.write('World begint op positie: ' + a.indexOf("World")); document.write('<BR>'); document.write('Positie 6 t/m 11: ' + a.substring(6,11)); document.write('<BR>'); document.write('World vervangen door Plantet: ' + a.replace("World","Planet")); </script> </body> </html>
Download hier het bestand.