We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a251adc commit b19f8deCopy full SHA for b19f8de
22.RedundantFunction.js
@@ -0,0 +1,17 @@
1
+// A Redundant Function
2
+
3
+// Write a function redundant that takes in a string str and returns a function that returns str.
4
5
+function redundant(str) {
6
+ return function () {
7
+ return str
8
+ }
9
+}
10
11
+const f1 = redundant("apple")
12
+const f2 = redundant("pear")
13
+const f3 = redundant("")
14
15
+console.log(f1()) // f1() ➞ "apple"
16
+console.log(f2()) // f2() ➞ "pear"
17
+console.log(f3()) // f3() ➞ ""
0 commit comments