Skip to content

Instantly share code, notes, and snippets.

@Yigaue
Created May 14, 2020 22:57
Show Gist options
  • Save Yigaue/7989a2a776f232f85da06af63a311057 to your computer and use it in GitHub Desktop.
Save Yigaue/7989a2a776f232f85da06af63a311057 to your computer and use it in GitHub Desktop.
data.map(item => {
if (item.price > 100) {
return {
id: item.id,
title: item.title,
price: item.price * (1 - 0.2)
};
}
return item;
});
console.log(data);
// result
/*
0: {id: 1, title: "Don't Waste your life ", price: 33, Author: "John Piper"}
1: {id: 2, title: "Living for a greater purpose", price: 12, Author: "JH Baritam"}
2: {id: 3, title: "The call for Mercy", price: 324}
3: {id: 4, title: "Heart Blindness", price: 440}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment