← Back to challenges

Front 3 - Slice Check Repeat Concatenate

JavaScriptHardstringsconditions

Instructions

Create a function that takes a string; we'll say that the front is the first three characters of the string. If the string length is less than three characters, the front is whatever is there. Return a new string, which is three copies of the front.

Examples

frontThree("Python") ➞ "PytPytPyt"

frontThree("Cucumber") ➞ "CucCucCuc"

frontThree("bioshock") ➞ "biobiobio"
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Extract City Facts