Change array elements in Javascript

<button onclick="changeElement()">Chnage Element</button>

<p id="demo"></p>

<script>
var courses = ["javascript", "php", "angularjs", "node js"];
document.getElementById("demo").innerHTML = courses;

function changeElement() {
courses[1]= 'Ajax';
document.getElementById("demo").innerHTML = courses;
}
</script>

Share This:

Leave a Reply

Your email address will not be published. Required fields are marked *