Javascript Challenges - Array Sum

  Рет қаралды 18,933

Coding Addict

Coding Addict

5 жыл бұрын

Javascript Challenges - Array Sum
COUPONS BELOW!!!!!!
REACT
www.udemy.com/draft/2018828/?...
JAVASCRIPT COURSE
www.udemy.com/javascript-tuto...
BOOTSTRAP COURSE
www.udemy.com/bootstrap-4-bet...
IN DEPTH HTML AND CSS
www.udemy.com/in-depth-html-c...
RESPONSIVE WEBISTES
www.udemy.com/responsive-webs...
JQUERY COURSE
www.udemy.com/jquery-tutorial...
FLEXBOX COURSE
www.udemy.com/css-flexbox-tut...
GRID COURSE
www.udemy.com/css-grid-tutori...
RESPONSIVE COFFEE SHOW WEBSITE
www.udemy.com/responsive-coff...
RESPONSIVE CAR DEALERSHIP
www.udemy.com/responsive-car-...
COUPONS BELOW!!!!!!
JAVASCRIPT COURSE
www.udemy.com/javascript-tuto...
BOOTSTRAP COURSE
www.udemy.com/bootstrap-4-bet...
IN DEPTH HTML AND CSS
www.udemy.com/in-depth-html-c...
RESPONSIVE WEBISTES
www.udemy.com/responsive-webs...
JQUERY COURSE
www.udemy.com/jquery-tutorial...
FLEXBOX COURSE
www.udemy.com/css-flexbox-tut...
GRID COURSE
www.udemy.com/css-grid-tutori...
Products I Use:
Microphone - Shure SM7B - amzn.to/3fX55aD
Headphones - Shure AONIC 50 - amzn.to/3zbkxHC
Desk-Mounted Microphone Stand - amzn.to/3x3MBuS
Crossover - dbx 234s - amzn.to/3xcryGC
Audio Interface - Focusrite Scarlett 2i2 3rd Gen - amzn.to/3pt1wMx
Cheaper Microphone (My first mic) - Blue Yeti USB Mic amzn.to/3iliwTm
Blue Light Blocking Glasses - amzn.to/3fZASrv
Apple MacBook Pro 13.3" - amzn.to/3z5QDEK
iMac - amzn.to/3glWmOe
Second Monitor - LG 4K UHD 27UD88 - amzn.to/3ckdwdV
Wifi Router - TP-Link AC1900 - amzn.to/34ZSddz
Desk Chair - amzn.to/3ikNbQJ
Standing Desk - amzn.to/3zdKVAJ
Books I Recommend:
The Subtle Art of Not Giving a F*ck - amzn.to/3v9t8Yi
The Tipping Point - amzn.to/3gCslKj
Atomic Habits - amzn.to/3x52xNa
12 Rules for Life - amzn.to/3gln8pN
Deep Work - amzn.to/3cyAgqu
Digital Minimalism - amzn.to/3gao69A
A World Without Email - amzn.to/351Swoe
Rich Dad Poor Dad - amzn.to/3v8RWQ6
Rich Dad's Cashflow Quadrant - amzn.to/3ivt1Uk
Check out My Amazon Store for more products and books recommendations - www.amazon.com/shop/codingaddict
Disclosure: This video is not sponsored. Some links above are affiliate links, and l may earn a small commission from any purchases at no additional cost to you. Thank you for supporting my channel!

Пікірлер: 33
@bulatbaltin5975
@bulatbaltin5975 4 жыл бұрын
Thanks a lot! One more solution function arraySum(arr) { let sum = 0; let max = 0; arr.forEach((num) => { if (max < num) { max = num; } sum += num; }) return (sum - max) === max; }
@DEV_XO
@DEV_XO 5 жыл бұрын
Amazing man, im enjoying this challenges. Hope you keep uploading stuff like this, some of us "knows the javascript surface", but didn't really knows how to deal with this kind of things, and well it really helps. Thanks a lot.
@thelostvorg7805
@thelostvorg7805 2 жыл бұрын
Answers can differ but here is mine function arraySum(arr){ const arrayMax = Math.max(...arr); return arr.reduce((t,p)=>t+p) - arrayMax === arrayMax }
@victorvlas1241
@victorvlas1241 5 жыл бұрын
function ArraySum(arr) { const max = Math.max.apply(null, arr) return arr .filter(el => el !== max) .reduce((curr, acc) => curr + acc, 0) === max }
@noirsociety
@noirsociety 3 жыл бұрын
function arraySum(arr) { const high = Math.max(...arr); const sum = arr.reduce((acc,num) => acc + num, 0) - high; return sum === high; } console.log(arraySum([1,2,4,6,13])); // true console.log(arraySum([1,2,4,34,22])); // false
@mounirelardi1201
@mounirelardi1201 3 жыл бұрын
const arraySum = arr => { let result = 0; for (const num of arr) { result += num; } return result - Math.max(...arr) === Math.max(...arr) } console.log(arraySum([1,2,3,7]))
@SaliAalaNabiyak
@SaliAalaNabiyak Жыл бұрын
my little solution : function arraysum(arr) { let maxvalue = Math.max(...arr) let newarr = arr.filter((e) => { return e !== maxvalue }).reduce((pr, cu) => { return pr + cu }) if (newarr !== maxvalue){ return "the sum of the array except the max value doesn't equal the max value" } return 'yaaay it worked' } console.log(arraysum([2, 5, 7, 6, 1, 20])) > the output is: the sum of the array except the max value doesn't equal the max value console.log(arraysum([2, 5, 7, 6, 20])) > the output is: yaay it worked
@TheJenasandeep
@TheJenasandeep 3 жыл бұрын
I learn how to sort , difference between map and forEach and solutions to this type of coddding problem ❤️
@EMartinezOliver
@EMartinezOliver 4 жыл бұрын
function sum(arr){ let others = [] let restSum let max = Math.max(...arr) arr.filter(item => { if (item != max){ others.push(item) } }) restSum = others.reduce((a,b)=>{ return a + b }) if (max === restSum){ return true } else { return false} }
@eskandarabedini6389
@eskandarabedini6389 2 жыл бұрын
Lots of thanks for your amazing course.
@moulaoui1279
@moulaoui1279 Жыл бұрын
const sum = (...values) => { const max = Math.max(...values); return max === values.reduce((acc,current) => acc+current ,0) / 2 }
@_wayne7928
@_wayne7928 3 жыл бұрын
function arraySum(arr){ toSumArray = arr.slice(0,(arr.length)-1) sumResult = toSumArray.reduce((x,y)=>x+y) if(sumResult == arr[arr.length-1]) return true else return false }
@oguzakankan518
@oguzakankan518 5 жыл бұрын
Thank you for Vanilla js. I'll buy your js course.
@CodingAddict
@CodingAddict 5 жыл бұрын
Thank you for your support!
@entertainment11378
@entertainment11378 3 жыл бұрын
How can we do sum of uniques items in object array [ {id :1,chat: 2},{id :1, chat:3}] result should be [{ id:1, chat : 5}] ?
@mickaelrichard7255
@mickaelrichard7255 2 жыл бұрын
function ArraySum(arr){ let largest = 0 const sum = arr.reduce((acc,item)=>{ if(item>largest) largest = item return acc += item },0) return largest === sum-largest } console.log(ArraySum([1,2,4,6,13]))
@bikramchettri9405
@bikramchettri9405 5 жыл бұрын
Thanks
@ogzhn
@ogzhn 2 жыл бұрын
function arraySum(arr) { const maxNumber = Math.max(...arr) let total = 0; for (let i = 0; i < arr.length; i++) total+= arr[i] return total % maxNumber === 0 }
@tigrangrigoryan6157
@tigrangrigoryan6157 4 жыл бұрын
function ArraySum(arr) { let tempArr = arr.sort((a, b) => a - b), sum = 0; for (let i = 0; i < tempArr.length - 1; i++) { sum += tempArr[i]; } return sum === tempArr[tempArr.length - 1]; }
@hareeshsapparad2845
@hareeshsapparad2845 3 жыл бұрын
function ArraySum(arr){ var result = 0; var maxVal = Math.max(...arr); for(let i = 0; i < arr.length; i++){ result += arr[i]; } if(result == (maxVal*2)){ return true } return false; } ArraySum([1,2,3,6]);//true ArraySum([1,2,3,6,7]);//false
@roman4889
@roman4889 2 жыл бұрын
const getSumEqualsMaxNum = arr => { const sum = arr.reduce((sum, curr) => sum + curr); const max = Math.max(...arr); return max === sum - max; }
@bishalshah1465
@bishalshah1465 3 жыл бұрын
Using filter and reduce const arraySum = (arr) => { const max = Math.max(...arr); return arr .filter((el) => el !== max) .reduce((a, b) => a + b)=== max; };
@ovuobachidera3987
@ovuobachidera3987 2 жыл бұрын
this is really good thnks for the share
@ganeshpbharadwaj8773
@ganeshpbharadwaj8773 5 ай бұрын
function arraySum(arr){ let total = 0; for(let num of arr){ if (num < Math.max(...arr)){ total += num; } } return total == Math.max(...arr); } console.log(arraySum([1,2,4,6,13])); console.log(arraySum([1,2,4,34,22]));
@davidpocsai3419
@davidpocsai3419 3 жыл бұрын
Can someone come up with a shorter solution than this? const Arraysum = (arr) => Math.max(...arr) * 2 === arr.reduce((a, b) => a + b,0);
@mahmoudelkhadragy8154
@mahmoudelkhadragy8154 3 жыл бұрын
function arraySum(arr) { let max = Math.max(...arr); let newArr = arr.filter((num) => num !== max); let acc = newArr.reduce((acc, num) => (acc += num)); if (acc === max) { return true; } return false; } console.log(arraySum([1, 2, 4, 6, 13])); //true console.log(arraySum([1, 2, 4, 34, 22])); //false
@sagartechnosoft2807
@sagartechnosoft2807 4 жыл бұрын
let arr = [1,2,3,4,5]; let arrSum = (arr) => { let total = 0; arr.forEach(element => { total = total + element; }); return total } console.log(arrSum(arr));
@emre-mz4sc
@emre-mz4sc Жыл бұрын
my solution: function sumAll(arr) { let sum = 0; let biggest = Math.max(...arr); let array = arr.filter((item) => item !== biggest); for (number of array) { sum = sum + number; } if (sum === biggest) return true; else { return false; } } console.log(sumAll([1, 2, 4, 6, 13]));
@KhanhPham-jq7cf
@KhanhPham-jq7cf 3 жыл бұрын
Just one line of code to solve the problem, take a look: const ArraySum = (arr) => arr.reduce((sum, value) => sum+value, 0) === 2*arr.sort((a,b) => b-a)[0] console.log(ArraySum([1, 6, 4, 2, 13])) // true console.log(ArraySum([1, 2, 4, 34, 22])) // false
@rajatgupta9582
@rajatgupta9582 3 жыл бұрын
function ArraySum(arr) { let sum = 0 var max = Math.max(...arr) for (let i = 0; i < arr.length; i++) { if (arr[i] === max) { continue } sum += arr[i] } return sum === max }
Javascript Challenges - Math Sequences
12:21
Coding Addict
Рет қаралды 20 М.
Who has won ?? 😀 #shortvideo #lizzyisaeva
00:24
Lizzy Isaeva
Рет қаралды 64 МЛН
Sigma Kid Hair #funny #sigma #comedy
00:33
CRAZY GREAPA
Рет қаралды 30 МЛН
DAD LEFT HIS OLD SOCKS ON THE COUCH…😱😂
00:24
JULI_PROETO
Рет қаралды 13 МЛН
Javascript Challenges - Repeated Numbers
12:11
Coding Addict
Рет қаралды 7 М.
Javascript Challenges - Unique Values with Set()
4:35
Coding Addict
Рет қаралды 6 М.
Javascript Challenges - Second Value
6:06
Coding Addict
Рет қаралды 5 М.
Javascript Challenges - Multiply Arguments
8:22
Coding Addict
Рет қаралды 8 М.
Top 10 CSS One Liners That Will Blow Your Mind
13:34
developedbyed
Рет қаралды 925 М.
JavaScript Problem: Counting Duplicate Elements in an Array
13:10
All Things JavaScript, LLC
Рет қаралды 10 М.
Javascript Challenges - Regex Palindrome
9:11
Coding Addict
Рет қаралды 8 М.
5 JavaScript Concepts You HAVE TO KNOW
9:38
James Q Quick
Рет қаралды 1,4 МЛН
Who has won ?? 😀 #shortvideo #lizzyisaeva
00:24
Lizzy Isaeva
Рет қаралды 64 МЛН