Imperative code - you telling your program how to do something
var numbers = [1,2,3,4];
var total = 0;
for(var i =0; i < numbers.length; i++) {
total += numbers[i]
}
// we explicitly say a list of things for the program to do
Declarative code - you telling your program what you want to do
var numbers = [1,2,3,4];
numbers.reduce(function (previous, current) {
return previous + current
}, 0);
Imperative code - you telling your program how to do something
Declarative code - you telling your program what you want to do