the background color should change on clicking the button there is one rule the button should be created by matrix as shown bellow.the error is red is the only output comming while clicking any button
var currColor = 5,
flag = 1;
var colors = ['red', 'blue', 'green', 'yellow', 'black'];
for (var i = 0; i < 5; i++) {
document.write('<input type="button" onclick="change()" id="btn" value=' + colors[i] + ' style="background-color:' + colors[i] + ' ;"></input>');
}
function change(i) {
var colorsName = document.getElementById('btn').value;
document.body.style.backgroundColor = colorsName;
}