L
Size: a a a
L
AK
L
L
L
НА
AK
НА
L
DE
L
НА
L
НА
НА
DE
L
function greatestProduct(digitsStr) {
let maxProduct = Number.NEGATIVE_INFINITY;
let offset = 0
while (true) {
let get5 = digitsStr.substr(offset, 5)
if ( get5.length < 5 ) break
let product = get5.split('').reduce( (a, b) => a * b, 1 )
if ( product > maxProduct )
maxProduct = product
offset++
}
return maxProduct
}
L
const greatestProduct = s => sя так решил
.split("")
.reduce((m, v, i, a) =>
i > a.length - 5 ? m :
Math.max(m, a.slice(i, i + 5).reduce((s, v) => s * v, 1)),
Number.NEGATIVE_INFINITY)
DE
js
function greatestProduct(digitsStr) {
let maxProduct = Number.NEGATIVE_INFINITY;
let offset = 0
while (true) {
let get5 = digitsStr.substr(offset, 5)
if ( get5.length < 5 ) break
let product = get5.split('').reduce(
676334445/source.js:9
});
^
SyntaxError: Unexpected token }
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:616:28)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Function.Module.runMain (module.js:693:10)
at startup (bootstrap_node.js:188:16)
at bootstrap_node.js:609:3
L