* feat(tools): add seed/solution restore script * chore(curriculum): remove empty sections' markers * chore(curriculum): add seed + solution to Chinese * chore: remove old formatter * fix: update getChallenges parse translated challenges separately, without reference to the source * chore(curriculum): add dashedName to English * chore(curriculum): add dashedName to Chinese * refactor: remove unused challenge property 'name' * fix: relax dashedName requirement * fix: stray tag Remove stray `pre` tag from challenge file. Signed-off-by: nhcarrigan <nhcarrigan@gmail.com> Co-authored-by: nhcarrigan <nhcarrigan@gmail.com>
		
			
				
	
	
	
		
			2.1 KiB
		
	
	
	
	
	
	
	
			
		
		
	
	id, title, challengeType, forumTopicId, dashedName
| id | title | challengeType | forumTopicId | dashedName | 
|---|---|---|---|---|
| 5e6dd14192286d95fc43046e | Longest string challenge | 5 | 385275 | longest-string-challenge | 
--description--
In this challenge, you have to find the strings that are the longest among the given strings.
--instructions--
Write a function that takes an array of strings and returns the strings that have a length equal to the longest length.
--hints--
longestString should be a function.
assert(typeof longestString == 'function');
longestString(["a", "bb", "ccc", "ee", "f", "ggg"]) should return a array.
assert(Array.isArray(longestString(['a', 'bb', 'ccc', 'ee', 'f', 'ggg'])));
longestString(["a", "bb", "ccc", "ee", "f", "ggg"]) should return ["ccc", "ggg"]'.
assert.deepEqual(longestString(['a', 'bb', 'ccc', 'ee', 'f', 'ggg']), [
  'ccc',
  'ggg'
]);
longestString(["afedg", "bb", "sdccc", "efdee", "f", "geegg"]) should return ["afedg", "sdccc", "efdee", "geegg"].
assert.deepEqual(
  longestString(['afedg', 'bb', 'sdccc', 'efdee', 'f', 'geegg']),
  ['afedg', 'sdccc', 'efdee', 'geegg']
);
longestString(["a", "bhghgb", "ccc", "efde", "fssdrr", "ggg"]) should return ["bhghgb", "fssdrr"].
assert.deepEqual(
  longestString(['a', 'bhghgb', 'ccc', 'efde', 'fssdrr', 'ggg']),
  ['bhghgb', 'fssdrr']
);
longestString(["ahgfhg", "bdsfsb", "ccc", "ee", "f", "ggdsfg"]) should return ["ahgfhg", "bdsfsb", "ggdsfg"].
assert.deepEqual(
  longestString(['ahgfhg', 'bdsfsb', 'ccc', 'ee', 'f', 'ggdsfg']),
  ['ahgfhg', 'bdsfsb', 'ggdsfg']
);
longestString(["a", "bbdsf", "ccc", "edfe", "gzzzgg"]) should return ["gzzzgg"].
assert.deepEqual(longestString(['a', 'bbdsf', 'ccc', 'edfe', 'gzzzgg']), [
  'gzzzgg'
]);
--seed--
--seed-contents--
function longestString(strings) {
}
--solutions--
function longestString(strings) {
    var mx = 0;
    var result = []
    strings.forEach(function (e) {
        if (e.length > mx) {
            mx = e.length
            result = [e]
        } else if (e.length == mx)
            result.push(e)
    })
    return result
}