logo CodeStepByStep logo

starString

Language/Type: JavaScript recursion
Author: Melissa Hovik (on 2016/09/25)

Write a recursive function named starString that accepts an integer parameter n and returns a string of stars (asterisks) 2n long (i.e., 2 to the nth power). For example:

Call Return Reason
starString(0) "*" 20 = 1
starString(1) "**" 21 = 2
starString(2) "****" 22 = 4
starString(3) "********" 23 = 8
starString(4) "****************" 24 = 16
Function: Write a JavaScript function as described, not a complete program.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.