Skip to main content

Command Palette

Search for a command to run...

[JavaScript] PROJECT: "Bankist" App - The Filter Method

Published
•View as Markdown
[JavaScript] PROJECT: "Bankist" App - The Filter Method
const movements = [200, 450, -400, 3000, -650, -130, 70, 1300];

const deposite = movements.filter(function (mov) {
  return mov > 0; // filter method return boolean value
});
console.log(movements);
console.log(deposite);

const depositeFor = [];
for (const mov of movements) if (mov > 0) depositeFor.push(mov);
console.log(depositeFor); // same result here with simple looping

const withdrawals = movements.filter(mov => mov < 0);

console.log(withdrawals);

filter method.PNG

JavaScript

Part 1 of 50

More from this blog

Jayden's Blog

166 posts