+ 2
is var hypeup function when it run why (adore(x)) runs first
confused with output become input function in var hypeup function complexity and why just calling function doesnt give any output plz fixed the result as 'Js rocks, y'all!' var ender = (input) => (ending) => input + ending; var adore = ender("rocks"); var announce = ender(",y'll"); var exclaim = ender("!"); var hypeup = (x) => exclaim(announce(adore(x))); hypeup("Js")
3 Answers
+ 2
Thats correctđđ
String reference:
https://www.w3schools.com/jsref/jsref_obj_string.asp
Array reference:
https://www.w3schools.com/jsref/jsref_obj_array.asp
+ 3
if there is not space in ender('rocks') it split every single char if i put space ender(' rocks ') it split in words.
+ 2
The adore(x) is nested therefore executed first.
There will be no output generated if you did not declare it to do so to an alert, DOM, consolelog, etc.
Without it, the code still be executed.
For example you can monitor/execute/debug an function inside:
console.log(hypeup()); // or
alert(typeof hypeup());
To solve your required output, it can be done in many ways from this point.
Re-assamble your code so the output will be correct for example.
But if you want the code to be the same you can:
- split() the string at the whitespace to be converted as an array which can be reversed. This will result that each word will be an array element.
- reverse() the array.
- join() the array back together to be converted back to a string.
Have a look at the changes, hope it helpsđ
https://code.sololearn.com/WV3r3RdOzZG8/?ref=app