Ini tampilah awal --->
source :
<html>
<head>
</head>
<body>
<script type="text/javascript">
var x = prompt("Masukkan bilangan :");
var g = 0;
var jml = 0;
for(i=1;i<=x;i++){
for(j=1;j<=i;j++){
document.write(j);
if(j<i){
document.write("+");
}else{
document.write("=");
}
g+=j;
}
document.write(g);
document.write("<br>")
jml+=g;
g = 0;
}
document.write("total = "+jml);
</script>
</body>
</html>
coba simpan code / source tsb dengan menggunakan notepad berekstensi .html
Tampilan akhir setelah menginputkan 5 --->
source :
<html>
<head>
</head>
<body>
<script type="text/javascript">
var x = prompt("Masukkan bilangan :");
var g = 0;
var jml = 0;
for(i=1;i<=x;i++){
for(j=1;j<=i;j++){
document.write(j);
if(j<i){
document.write("+");
}else{
document.write("=");
}
g+=j;
}
document.write(g);
document.write("<br>")
jml+=g;
g = 0;
}
document.write("total = "+jml);
</script>
</body>
</html>
coba simpan code / source tsb dengan menggunakan notepad berekstensi .html
-------------------------------------------------------------------------------
Komentar
Posting Komentar