// Imperattive (How - means not have trust that's y we telling how gonna execute things)
var numbers = [3,2,4,5]
var total = 0
for(var i=0; i< numbers.length; i++){
total += numbers[i]
}
// Declarative (What - have trust no matter we know will happen exactly what we want)
var numbers = [3,2,4,5]
numbers.reduce(function(previous, current){
return previous + current
})
- Reduce side effects
- Minimize mutability
- More readable code
- Less bugs