Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@
<!-- ---------------------------------------------------------------------------------- -->
<body> <!-- body begins here -->


The quickest of brown foxes.
<button onclick="square()">Get Square num</button>
<button onclick="interval()">Print interval</button>
<button onclick="editArray()">Edit Array</button>
<button onclick="output()">Fibonacci numbers</button>



Expand Down
45 changes: 45 additions & 0 deletions js/slide22.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
function square(){
do{
var v = prompt("Please input an integer");
}while(v <= 0 || v >= 100)
console.log(v *v);
}

function interval(){
var start = prompt("please enter L:");
var end = prompt("please enter U:");
var string = "";
for(var i = start; i < end; i++){
string = string + i + " ";
}
console.log(string);
}

function editArray(){
var myData = new Array(); //initializing an array
for(var i = 0; i < 10; i++){
myData[i] = 1;
console.log(myData[i]);
}
var index = 0; //default untyped, should give a value
var value;
while(index >= 0 && index < 10){
index = prompt("input the cell index ");
value = prompt("input its value");
myData[index] = parseInt(value);
console.log(myData);
}
}

function fib(n){
if (n == 0) return 0;
if (n == 1) return 1;
if (n == 2) return 1;
return fib(n-1)+fib(n-2);
}

function output() {
for (var i = 0; i < 60; i++){
console.log(fib(i));
}
}