From ab275fc7e793dbc7984c8317892d29afdac0276e Mon Sep 17 00:00:00 2001 From: ARSHAD KALLARAKKAL <137690592+Arshad401@users.noreply.github.com> Date: Sat, 21 Oct 2023 07:02:25 +0400 Subject: [PATCH] Create array-reducer.js --- array-reducer.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 array-reducer.js diff --git a/array-reducer.js b/array-reducer.js new file mode 100644 index 0000000..934b563 --- /dev/null +++ b/array-reducer.js @@ -0,0 +1,13 @@ +from functools import reduce + +# Sample array of numbers +numbers = [1, 2, 3, 4, 5] + +# Define a function to add two numbers +def add(x, y): + return x + y + +# Use the reduce function to find the sum of elements in the array +result = reduce(add, numbers) + +print("Sum of elements:", result)