I want to create a button that changes the value of an element in an array. I am trying to do this with the following code, but the element is not changing. As a newcomer to self-study, I will probably miss something very obvious, and I would appreciate it if someone could point this out to me.
Thank you for your responses!
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Change Array Value</title>
</head>
<body>
<textarea id="log2"></textarea>
<input type="button" onClick="uClicked();" value="Click!">
<script>
var fer=[];
for (i=0; i< 15; i++){
fer[i]=i+1;
}
function uClicked(fer){
fer[12] = 10;
return fer[12];
}
log2.value = "fer[12]= " + fer[12];
</script>
</body>
</html>
source
share