Skip to content

Instantly share code, notes, and snippets.

@goodanthony
Created February 16, 2022 23:18
Show Gist options
  • Save goodanthony/7e2b3a68467f4c16be4876e8f3250780 to your computer and use it in GitHub Desktop.
Save goodanthony/7e2b3a68467f4c16be4876e8f3250780 to your computer and use it in GitHub Desktop.
Code assessment
const ArrayChallenge = (arr) => {
const result = arr.reduce((acc, curr) => {
return acc + curr;
}, 0);
const double = result * 2;
const check = arr.some(e => {
return double > e * 2;
});
return check ? "true" : "false";
}
@goodanthony
Copy link
Author

goodanthony commented Feb 16, 2022

def array_challenge(arr)
arr.each do |x|
arr.each do |y|
if x * y > arr.reduce(:+) * 2
return "true"
end
end
end
"false"
end``

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment