Skip to content

Instantly share code, notes, and snippets.

@ferditarakci
Last active October 7, 2022 21:15
Show Gist options
  • Save ferditarakci/24b38b0937326bbe2c787e43fa055151 to your computer and use it in GitHub Desktop.
Save ferditarakci/24b38b0937326bbe2c787e43fa055151 to your computer and use it in GitHub Desktop.
const multiply = function(a, b) {
return a * b;
}
multiply(3, 5);
// output: 15
multiply(2, 40);
// output: 80
// ---------------------------
const filtered = function(arr) {
return arr.filter(function(val) {
return val > 4;
})
}
filtered([1, 2, 3, 4, 5, 6, 7, 8, 9]);
// output: [5, 6, 7, 8, 9]
filtered([1, 2, 3, 4]);
// output: []
// ---------------------------
const double = function(arr) {
return arr.map(function(val) {
return val * 2;
})
}
double([1, 2, 3, 4, 5, 6, 7, 8, 9]);
// output: [2, 4, 6, 8, 10, 12, 14, 16, 18]
// ---------------------------
const isThere = function(name) {
const arr = ["Erik", "Elma", "Muz", "Kavun"];
return arr.some(function(val) {
return val === name;
})
}
isThere("Elma");
// output: true
isThere("Çilek");
// output: false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment