Q1: Try to understand what's the perpose of this paragraph of code. And fix it.
<!doctype html>
<title></title>
<meta charset="utf-8"/>
<script type="text/javascript">
window.onload = function(){
for(var i=1; i < 4; i++){
var id = document.getElementById("a" + i);
id.onclick = function(){
alert(i);
}
}
}
</script>
<ul>
<li id="a1">aa</li>
<li id="a2">aa</li>
<li id="a3">aa</li>
</ul>
Q2: What’s the value of 'result'?
var result = “hello, world!”.replace(“o”,”i”);
Q3: What’s the output?
var foo = “hello”;
function fxn(){
alert(foo);
var foo = “bye”;
}
fxn();
alert(foo);