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]); | |
} | |
} | |
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(); | |
return getNewsContent(allNews, 'javascript'); | |
} | |
function getRustNews() { | |
const allNews = getNewsFromWeb(); | |
return getNewsContent(allNews, 'rust'); | |
} |
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 startProgram() { | |
if (!window.indexedDB) { | |
throw new Error("Browser doesn't support indexedDB"); | |
} | |
initDatabase(); | |
setListeners(); | |
printEmployeeList(); | |
} |
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 getNews(type) { | |
const allNews = getNewsFromWeb(); | |
return getNewsContent(allNews, type); | |
} | |
function getNewsContent(newsList, type) { | |
return newsList | |
.filter(newsItem => newsItem.type === type) | |
.map(newsItem => newsItem.content); | |
} |
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 startProgram() { | |
if (!window.indexedDB) { | |
window.alert("Browser not support indexeDB"); | |
} else { | |
let openRequest = indexedDB.open("store", 1); | |
openRequest.onupgradeneeded = () => {}; | |
openRequest.onerror = () => { | |
console.error("Error", openRequest.error); |
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
if (isWildPokemon) { | |
usePokeball(); | |
} | |
if (isPokemon && !isSaved) { | |
save(pokemon); | |
} |
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
if (isWildPokemon === true) { | |
usePokeball(); | |
} | |
if (isPokemon === true && isSaved === false) { | |
save(pokemon); | |
} |
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 isWildPokemon(pokemon) { | |
if (pokemon.isWild) { | |
return true; | |
} else { | |
return false; | |
} | |
} | |
function isSaved(pokemonId) { | |
if (this.savedPokemon.some(({ id }) => id === pokemonId)) { |
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 isWildPokemon(pokemon) { | |
return pokemon.isWild; | |
} | |
function isSaved(pokemonId) { | |
return this.savedPokemon.some(({ id }) => id === pokemonId); | |
} |
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 attack(pokemon) { | |
if (pokemon.type === 'water') { | |
useWaterAttack(); | |
} else if (pokemon.type === 'fire') { | |
useFireAttack(); | |
} else if (pokemon.type === 'ice') { | |
useIceAttack(); | |
} else if (pokemon.type === 'electric') { | |
useElectricAttack(); | |
} else { |