Skip to content

Instantly share code, notes, and snippets.

@3rdp
Forked from anonymous/countOfSymbol.js
Last active November 27, 2017 21:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 3rdp/3b8d115ea40b18f9aa8cc43d2d710f66 to your computer and use it in GitHub Desktop.
Save 3rdp/3b8d115ea40b18f9aa8cc43d2d710f66 to your computer and use it in GitHub Desktop.
Test quest javascript / Save The Day
/*
* Finished: 30 min
*/
function countOfSymbol(arr) {
let filter2 = (v) => v == '2'
return arr.map((v) => v.toString().split(''))
.reduce((prev, curr) => prev.filter(filter2).length >= curr.filter(filter2).length ? prev : curr, [])
.join('') || null
}
let simpleArr = [11, 22, 23]
let dumb = [1]
console.log(countOfSymbol(dumb))
/*
* Finished: 20 min
*/
// You will be given a string of space separated words.
// The task is to remove the first
// and the last letter from each word.
// For example:
// 'Fortune favors the bold' to 'ortun avor h ol'.
function countOfSymbol(arr) {
let filter2 = (v) => v == '2'
return arr.map((v) => v.toString().split(''))
.reduce((prev, curr) => prev.filter(filter2).length >= curr.filter(filter2).length ? prev : curr, [])
.join('') || null
}
let simpleArr = [11, 22, 23]
let dumb = [1]
console.log(countOfSymbol(dumb))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment