Fundamentals
Lists
Data Structures
Strings
Data Types
Convert Words To DuckDuckGo Query - ES6
When a human gives a list of words separated by commas, the computer sends back a list of DuckDuckGo™ images queries links.
searchDuckLinks("Dublin,Palerme,Cholet")
searchDuckLinks = (str) => str
.split(',')
.map(word => `https://duckduckgo.com/?q=${word}&iax=1&ia=images`)
describe("Solution", () => {
it("should test for something", () => {
Test.assertEquals(searchDuckLinks("orange")[0], "https://duckduckgo.com/?q=orange&iax=1&ia=images")
Test.assertEquals(searchDuckLinks("Dublin,Palerme,Cholet")[1], "https://duckduckgo.com/?q=Palerme&iax=1&ia=images")
Test.assertEquals(searchDuckLinks("Dublin,Palerme,Cholet")[2], "https://duckduckgo.com/?q=Cholet&iax=1&ia=images")
})
})