Last active
October 10, 2019 13:12
-
-
Save NyaGarcia/7f19fcd5211dc9b99fa1a957c9219f68 to your computer and use it in GitHub Desktop.
An example of duplicated code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getJavascriptNews() { | |
const allNews = getNewsFromWeb(); | |
const news = []; | |
for (let i = allNews.length - 1; i >= 0; i--){ | |
if (allNews[i].type === "javascript") { | |
news.push(allNews[i]); | |
} | |
} | |
return news; | |
} | |
function getRustNews() { | |
const allNews = getNewsFromWeb(); | |
const news = []; | |
for (let i = allNews.length - 1; i >= 0; i--){ | |
if (allNews[i].type === "rust") { | |
news.push(allNews[i]); | |
} | |
} | |
return news; | |
} | |
function getGolangNews() { | |
const news = []; | |
const allNews = getNewsFromWeb(); | |
for (let i = allNews.length - 1; i >= 0; i--) { | |
if (allNews[i].type === 'golang') { | |
news.push(allNews[i]); | |
} | |
} | |
return news; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment