{"id":8817,"date":"2022-09-15T16:57:24","date_gmt":"2022-09-15T11:27:24","guid":{"rendered":"https:\/\/jassweb.com\/solved\/solved-javascript-adding-values-of-key-value-pair-closed\/"},"modified":"2022-09-15T16:57:24","modified_gmt":"2022-09-15T11:27:24","slug":"solved-javascript-adding-values-of-key-value-pair-closed","status":"publish","type":"post","link":"https:\/\/jassweb.com\/solved\/solved-javascript-adding-values-of-key-value-pair-closed\/","title":{"rendered":"[Solved] JavaScript adding values of key value pair [closed]"},"content":{"rendered":"<p> [ad_1]<br \/>\n<\/p>\n<div id=\"answer-48874775\" class=\"answer js-answer accepted-answer js-accepted-answer\" data-answerid=\"48874775\" data-parentid=\"48874460\" data-score=\"0\" data-position-on-page=\"1\" data-highest-scored=\"1\" data-question-has-accepted-highest-score=\"1\" itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n<div class=\"post-layout\">\n<div class=\"votecell post-layout--left\"><\/div>\n<div class=\"answercell post-layout--right\">\n<div class=\"s-prose js-post-body\" itemprop=\"text\">\n<p>Suposing the JSON was valid as I expose, and you want the result in another array:<\/p>\n<pre><code>var foo = [\n{20: 24, 30: 37, 40: 17, 50: 16, 60: 5, 70: 2, day: \"1\"},\n\n{20: 69, 30: 163, 40: 88, 50: 42, 60: 27, 80: 2, \"-1\": 3, day: \"2\"},\n\n{20: 78, 30: 220, 40: 88, 50: 49, 60: 22, 70: 1, 130: 2, \"-1\": 9, day: \"3\"},\n\n{20: 14, 30: 18, 40: 7, 50: 10, 60: 3, day: \"4\"},\n\n{20: 21, 30: 63, 40: 22, 50: 9, 60: 5, \"-1\": 1, day: \"5\"},\n\n{20: 12, 30: 38, 40: 10, 50: 13, 60: 1, \"-1\": 1, day: \"6\"},\n\n{20: 23, 30: 39, 40: 21, 50: 5, 60: 1, \"-1\": 1, day: \"7\"},\n\n{20: 57, 30: 156, 40: 67, 50: 19, 60: 17, 70: 1, 80: 1, \"-1\": 5, day: \"8\"},\n\n{20: 67, 30: 169, 40: 86, 50: 56, 60: 30, \"-1\": 6, day: \"9\"},\n\n{20: 101, 30: 209, 40: 99, 50: 56, 60: 34, \"-1\": 10, day: \"10\"},\n\n{10: 1, 20: 108, 30: 223, 40: 134, 50: 60, 60: 40, 70: 3, 80: 2, 130: 3, \"-1\": 10, day: \"11\"},\n\n{10: 2, 20: 73, 30: 158, 40: 72, 50: 39, 60: 22, \"-1\": 11, day: \"12\"},\n\n{20: 66, 30: 126, 40: 59, 50: 26, 60: 12, 70: 2, \"-1\": 11, day: \"13\"},\n\n{10: 1, 20: 36, 30: 85, 40: 34, 50: 10, 60: 11, \"-1\": 14, day: \"14\"},\n\n{10: 1, 20: 57, 30: 146, 40: 43, 50: 33, 60: 12, 70: 1, \"-1\": 4, day: \"15\"},\n\n{20: 91, 30: 209, 40: 132, 50: 56, 60: 30, 70: 1, 80: 1, \"-1\": 5, day: \"16\"},\n\n{20: 74, 30: 185, 40: 73, 50: 34, 60: 21, 70: 1, 80: 1, \"-1\": 13, day: \"17\"},\n\n{20: 78, 30: 208, 40: 101, 50: 41, 60: 34, 80: 1, \"-1\": 7, day: \"18\"},\n\n{20: 85, 30: 244, 40: 111, 50: 53, 60: 35, 70: 1, \"-1\": 13, day: \"19\"},\n\n{20: 87, 30: 191, 40: 113, 50: 49, 60: 26, 70: 2, 130: 1, \"-1\": 37, day: \"20\"},\n\n{20: 91, 30: 170, 40: 77, 50: 45, 60: 18, 70: 2, \"-1\": 54, day: \"21\"},\n\n{20: 126, 30: 284, 40: 134, 50: 68, 60: 41, 80: 2, \"-1\": 11, day: \"22\"},\n\n{20: 101, 30: 238, 40: 100, 50: 50, 60: 29, 80: 1, \"-1\": 5, day: \"23\"},\n\n{20: 131, 30: 265, 40: 125, 50: 54, 60: 27, 80: 1, \"-1\": 12, day: \"24\"},\n\n{20: 91, 30: 244, 40: 138, 50: 66, 60: 29, 70: 1, 80: 1, 130: 2, \"-1\": 13, day: \"25\"},\n\n{20: 95, 30: 269, 40: 123, 50: 53, 60: 33, 130: 1, \"-1\": 14, day: \"26\"},\n\n{20: 110, 30: 221, 40: 83, 50: 42, 60: 23, 80: 2, \"-1\": 26, day: \"27\"},\n\n{20: 70, 30: 130, 40: 38, 50: 33, 60: 13, 80: 1, \"-1\": 2, day: \"28\"},\n\n{20: 122, 30: 310, 40: 160, 50: 53, 60: 31, 80: 2, 130: 1, \"-1\": 15, day: \"29\"},\n\n{20: 91, 30: 204, 40: 97, 50: 59, 60: 21, \"-1\": 13, day: \"30\"},\n\n{20: 97, 30: 206, 40: 125, 50: 53, 60: 27, 130: 1, \"-1\": 16, day: \"31\"}\n];\n\nlet bar = [];\nfor (let i = 0; i &lt; foo.length; i++) {\n  let sum = 0;\n    for (let property in foo[i]) {\n    if (foo[i].hasOwnProperty(property) &amp;&amp; property != 'day') {\n        \/\/ do stuff\n        sum += foo[i][property];\n    }\n  }\n  bar.push(sum);\n  console.log(bar[i]);\n}\n<\/code><\/pre>\n<\/p><\/div>\n<div class=\"mt24\"><\/div>\n<\/div>\n<p>            <span class=\"d-none\" itemprop=\"commentCount\">0<\/span> <\/p><\/div>\n<\/div>\n<p>[ad_2]<\/p>\n<p>solved JavaScript adding values of key value pair [closed] <\/p>\n","protected":false},"excerpt":{"rendered":"<p>[ad_1] Suposing the JSON was valid as I expose, and you want the result in another array: var foo = [ {20: 24, 30: 37, 40: 17, 50: 16, 60: 5, 70: 2, day: &#8220;1&#8221;}, {20: 69, 30: 163, 40: 88, 50: 42, 60: 27, 80: 2, &#8220;-1&#8221;: 3, day: &#8220;2&#8221;}, {20: 78, 30: 220, &#8230; <a title=\"[Solved] JavaScript adding values of key value pair [closed]\" class=\"read-more\" href=\"https:\/\/jassweb.com\/solved\/solved-javascript-adding-values-of-key-value-pair-closed\/\" aria-label=\"More on [Solved] JavaScript adding values of key value pair [closed]\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[320],"tags":[361,333],"class_list":["post-8817","post","type-post","status-publish","format-standard","hentry","category-solved","tag-arrays","tag-javascript"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>[Solved] JavaScript adding values of key value pair [closed] - JassWeb<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jassweb.com\/solved\/solved-javascript-adding-values-of-key-value-pair-closed\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"[Solved] JavaScript adding values of key value pair [closed] - JassWeb\" \/>\n<meta property=\"og:description\" content=\"[ad_1] Suposing the JSON was valid as I expose, and you want the result in another array: var foo = [ {20: 24, 30: 37, 40: 17, 50: 16, 60: 5, 70: 2, day: &quot;1&quot;}, {20: 69, 30: 163, 40: 88, 50: 42, 60: 27, 80: 2, &quot;-1&quot;: 3, day: &quot;2&quot;}, {20: 78, 30: 220, ... Read more\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jassweb.com\/solved\/solved-javascript-adding-values-of-key-value-pair-closed\/\" \/>\n<meta property=\"og:site_name\" content=\"JassWeb\" \/>\n<meta property=\"article:published_time\" content=\"2022-09-15T11:27:24+00:00\" \/>\n<meta name=\"author\" content=\"Kirat\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Kirat\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-javascript-adding-values-of-key-value-pair-closed\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-javascript-adding-values-of-key-value-pair-closed\/\"},\"author\":{\"name\":\"Kirat\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31\"},\"headline\":\"[Solved] JavaScript adding values of key value pair [closed]\",\"datePublished\":\"2022-09-15T11:27:24+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-javascript-adding-values-of-key-value-pair-closed\/\"},\"wordCount\":36,\"publisher\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\"},\"keywords\":[\"arrays\",\"javascript\"],\"articleSection\":[\"Solved\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-javascript-adding-values-of-key-value-pair-closed\/\",\"url\":\"https:\/\/jassweb.com\/solved\/solved-javascript-adding-values-of-key-value-pair-closed\/\",\"name\":\"[Solved] JavaScript adding values of key value pair [closed] - JassWeb\",\"isPartOf\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#website\"},\"datePublished\":\"2022-09-15T11:27:24+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-javascript-adding-values-of-key-value-pair-closed\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/jassweb.com\/solved\/solved-javascript-adding-values-of-key-value-pair-closed\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-javascript-adding-values-of-key-value-pair-closed\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/jassweb.com\/solved\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"[Solved] JavaScript adding values of key value pair [closed]\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/jassweb.com\/solved\/#website\",\"url\":\"https:\/\/jassweb.com\/solved\/\",\"name\":\"JassWeb\",\"description\":\"Build High-quality Websites\",\"publisher\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/jassweb.com\/solved\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\",\"name\":\"Jass Web\",\"url\":\"https:\/\/jassweb.com\/solved\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png\",\"contentUrl\":\"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png\",\"width\":693,\"height\":132,\"caption\":\"Jass Web\"},\"image\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31\",\"name\":\"Kirat\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1776403586\",\"contentUrl\":\"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1776403586\",\"caption\":\"Kirat\"},\"sameAs\":[\"http:\/\/jassweb.com\"],\"url\":\"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"[Solved] JavaScript adding values of key value pair [closed] - JassWeb","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/jassweb.com\/solved\/solved-javascript-adding-values-of-key-value-pair-closed\/","og_locale":"en_US","og_type":"article","og_title":"[Solved] JavaScript adding values of key value pair [closed] - JassWeb","og_description":"[ad_1] Suposing the JSON was valid as I expose, and you want the result in another array: var foo = [ {20: 24, 30: 37, 40: 17, 50: 16, 60: 5, 70: 2, day: \"1\"}, {20: 69, 30: 163, 40: 88, 50: 42, 60: 27, 80: 2, \"-1\": 3, day: \"2\"}, {20: 78, 30: 220, ... Read more","og_url":"https:\/\/jassweb.com\/solved\/solved-javascript-adding-values-of-key-value-pair-closed\/","og_site_name":"JassWeb","article_published_time":"2022-09-15T11:27:24+00:00","author":"Kirat","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Kirat","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jassweb.com\/solved\/solved-javascript-adding-values-of-key-value-pair-closed\/#article","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/solved-javascript-adding-values-of-key-value-pair-closed\/"},"author":{"name":"Kirat","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31"},"headline":"[Solved] JavaScript adding values of key value pair [closed]","datePublished":"2022-09-15T11:27:24+00:00","mainEntityOfPage":{"@id":"https:\/\/jassweb.com\/solved\/solved-javascript-adding-values-of-key-value-pair-closed\/"},"wordCount":36,"publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"keywords":["arrays","javascript"],"articleSection":["Solved"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/jassweb.com\/solved\/solved-javascript-adding-values-of-key-value-pair-closed\/","url":"https:\/\/jassweb.com\/solved\/solved-javascript-adding-values-of-key-value-pair-closed\/","name":"[Solved] JavaScript adding values of key value pair [closed] - JassWeb","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/#website"},"datePublished":"2022-09-15T11:27:24+00:00","breadcrumb":{"@id":"https:\/\/jassweb.com\/solved\/solved-javascript-adding-values-of-key-value-pair-closed\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jassweb.com\/solved\/solved-javascript-adding-values-of-key-value-pair-closed\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/jassweb.com\/solved\/solved-javascript-adding-values-of-key-value-pair-closed\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/jassweb.com\/solved\/"},{"@type":"ListItem","position":2,"name":"[Solved] JavaScript adding values of key value pair [closed]"}]},{"@type":"WebSite","@id":"https:\/\/jassweb.com\/solved\/#website","url":"https:\/\/jassweb.com\/solved\/","name":"JassWeb","description":"Build High-quality Websites","publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jassweb.com\/solved\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/jassweb.com\/solved\/#organization","name":"Jass Web","url":"https:\/\/jassweb.com\/solved\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/","url":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","contentUrl":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","width":693,"height":132,"caption":"Jass Web"},"image":{"@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31","name":"Kirat","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/image\/","url":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1776403586","contentUrl":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1776403586","caption":"Kirat"},"sameAs":["http:\/\/jassweb.com"],"url":"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/"}]}},"_links":{"self":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/8817","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/comments?post=8817"}],"version-history":[{"count":0,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/8817\/revisions"}],"wp:attachment":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/media?parent=8817"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/categories?post=8817"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/tags?post=8817"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}