Enieber Cunha
My name is Enieber Cunha and I living in Brazil. I am developer JS and Android and in love for User Exprience, functional programming and classical music.
Logic programming is a type of programming paradigm which is largely based on formal logic. Any program written in a logic programming language is a set of sentences in logical form, expressing facts and rules about some problem domain.. (Wikipidia)
https://en.wikipedia.org/wiki/Logic_programming
function isOlder(age) {
if (age >= 18) {
return true
} else {
return false
}
}
In computer science, functional programming is a programming paradigm—a style of building the structure and elements of computer programs—that treats computation as the evaluation of mathematical functions and avoids changing-state and mutable data. (wikipedia)
https://en.wikipedia.org/wiki/Functional_programming
const animals = [
{ name: "Toto", species: "dog"},
{ name: "Bidu", species: "dog"},
{ name: "Mial", species: "cat"},
{ name: "Garfield", species: "cat"},
{ name: "Ze", species: "parrot"},
]
var isDog = function(animal) {
return animal.species === "dog"
}
var isCat = function(animal) {
return animal.species === 'cat'
}
var dogs = animals.filter(isDog)
var cats = animals.filter(isCat)
console.log(dogs)
console.log(cats)
const animals = [
{ name: "Toto", species: "dog"},
{ name: "Bidu", species: "dog"},
{ name: "Mial", species: "cat"},
{ name: "Garfield", species: "cat"},
{ name: "Ze", species: "parrot"},
]
var isDog = function(animal) {
return animal.species === "dog"
}
isDog(animals[3]) //return is true
const animals = [
{ name: "Toto", species: "dog"},
{ name: "Bidu", species: "dog"},
{ name: "Mial", species: "cat"},
{ name: "Garfield", species: "cat"},
{ name: "Ze", species: "parrot"},
]
// isDog is a function
// [].filter() is a function
animals.filter(isDog)
/*
return [
{ name: "Toto", species: "dog"},
{ name: "Bidu", species: "dog"}
]
*/
function sum(n1, n2) {
return n1 + n2
}
sum(1,1) // 2
By Enieber Cunha
My name is Enieber Cunha and I living in Brazil. I am developer JS and Android and in love for User Exprience, functional programming and classical music.