Javascript: Longest substring

JS: Arrays
Last update: 29 Apr 11:19
0
Students

solution.js

Write and export as default a function that takes a string as input and returns the length of the longest sequence of unique characters. A substring may contain a single character. For instance, from the qweqrty string you can get the following substrings: qwe and weqrty. weqrty will be the longest one.

Examples

getLongestLength('abcdeef'); // 5
getLongestLength('jabjcdel'); // 7
getLongestLength(''); // 0

Tips

  • To get an array index of an element, use .indexOf() method

For full access to the challenge you need a professional subscription.

A professional subscription will give you full access to all Hexlet courses, projects and lifetime access to the theory of lessons learned. You can cancel your subscription at any time.

Get access
130
courses
900
exercises
2000+
hours of theory
3200
tests