Created
May 8, 2013 15:18
-
-
Save pgainda/5541170 to your computer and use it in GitHub Desktop.
To make the subset of the string include the character at the start index, set i equal to start in the first loop parameter.
To make the subset include the character at the end index, use the <= operator to compare i and end in the second loop parameter.
Since characters are numbered by ones, increment i by one in the third loop parameter.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Define substring here | |
function subString(input, start, end){ | |
var i; | |
this.input = input; | |
this.start = start; | |
this.end = end; | |
for(i=start;i<=end;i++){ | |
console.log(input[i]); | |
} | |
} | |
// Write test here: | |
// Call substring, passing "lorem ipsum dolor" to `input`, `6` to | |
// `start`, and `10` to `end`. | |
subString("lorem ipsum dolor",6,10); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment