'Did I break the console with my range function?
range = (arg1, arg2, arg3) => {
let arr = [];
let min = Math.min(arg1, arg2);
if (arg3 != undefined) {
// let i = min;
while (min <= Math.max(arg1, arg2)) {
min += arg3;
arr.push(min);
}
} else {
for (let i = min; i <= Math.max(arg1, arg2); i++) {
arr.push(i);
}
}
return arr;
}
console.log(range(1, 10));
// → [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
console.log(range(5, 2, -1));
// → [5, 4, 3, 2]
// console.log(sum(range(1, 10)));
// → 55
// sum = (arr) => {
// let sum = 0;
// for (let numbs of arr) {
// sum += numbs;
// }
// return sum;
// }
// console.log(sum(range(1,10)));
// // 55
I really can't see where I went wrong with this. What's wrong here exactly??
And what's up with the cryptic error messages:
#
# Fatal error in , line 0
# Fatal JavaScript invalid size error 169220804
#
#
#
#FailureMessage Object: 0000009A0CAFE560
1: 00007FF7D71E815F v8::internal::CodeObjectRegistry::~CodeObjectRegistry+114079
2: 00007FF7D710343F std::basic_ostream<char,std::char_traits<char> >::operator<<+65023
3: 00007FF7D7DE2EE2 V8_Fatal+162
4: 00007FF7D7966D35 v8::internal::FactoryBase<v8::internal::Factory>::NewFixedArray+101
5: 00007FF7D78271B2 v8::debug::Script::GetIsolate+16706
6: 00007FF7D769A9A1 v8::internal::CompilationCache::IsEnabledScriptAndEval+26913
7: 00007FF7D7B39701 v8::internal::SetupIsolateDelegate::SetupHeap+494417
8: 00000239C87C9080
Please someone help me, I feel like I am blind, I can't begin to comprehend whether there's even any errors in this function.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
