Challenge: Make a Sentence
This challenge will test your skills in implementing partial functions in JavaScript.
Problem statement #
Study the code given below:
Press + to interact
const sentence = (conjunction, ...otherWords) => {const commasJoiningWords = otherWords.slice(0,-1).join(", ");const lastWord = otherWords.pop();return `${commasJoiningWords} ${conjunction} ${lastWord}`;}console.log(sentence("and","mango","apple","peach"))console.log(sentence("or","bike","car","train"))
Observe the output and then try to understand what the sentence
function is doing. Currently, on line 6 we are ...
Access this course and 1400+ top-rated courses and projects.