Title: Chapter 4. Bubbles 2. · Issue #27 · bethrobson/Head-First-JavaScript-Programming · GitHub
Open Graph Title: Chapter 4. Bubbles 2. · Issue #27 · bethrobson/Head-First-JavaScript-Programming
X Title: Chapter 4. Bubbles 2. · Issue #27 · bethrobson/Head-First-JavaScript-Programming
Description: Hello everyone! I've got a question about the final version of the code in Chapter 4 (root: Chapter 4 -> bubbles2.html). The function getMostCostEffectiveSolution(scores, costs, highScore) is meant to choose the lower price for the highe...
Open Graph Description: Hello everyone! I've got a question about the final version of the code in Chapter 4 (root: Chapter 4 -> bubbles2.html). The function getMostCostEffectiveSolution(scores, costs, highScore) is meant...
X Description: Hello everyone! I've got a question about the final version of the code in Chapter 4 (root: Chapter 4 -> bubbles2.html). The function getMostCostEffectiveSolution(scores, costs, highScore) i...
Opengraph URL: https://github.com/bethrobson/Head-First-JavaScript-Programming/issues/27
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Chapter 4. Bubbles 2. ","articleBody":"Hello everyone! \r\nI've got a question about the final version of the code in Chapter 4 (root: Chapter 4 -\u003e bubbles2.html). The function getMostCostEffectiveSolution(scores, costs, highScore) is meant to choose the lower price for the highest scores that repeat twice. The best costs turned out to be .22 and .25. As a result of invoking the built-in return function, we get .22, but how does the function understand that we need a lower price, though we didn't mention any condition for that? \r\n\r\nfunction getMostCostEffectiveSolution(scores, costs, highScore) {\r\n\tvar cost = 100; // much higher than any of the costs\r\n\tvar index;\r\n\r\n\tfor (var i = 0; i \u003c scores.length; i++) {\r\n\t\tif (scores[i] == highScore) {\r\n\t\t\tif (cost \u003e costs[i]) {\r\n\t\t\t\tindex = i;\r\n\t\t\t\tcost = costs[i];\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn index;\r\n}","author":{"url":"https://github.com/Dexter1996777","@type":"Person","name":"Dexter1996777"},"datePublished":"2024-01-13T22:06:18.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/27/Head-First-JavaScript-Programming/issues/27"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:c7d4224e-dc8f-231a-57e6-1513c5f9e0b6 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8316:29F2AE:18A801D:219D9FC:697344F6 |
| html-safe-nonce | 9f02bfcd58510b1a68651ec67cce64729db5d8aae65741d874fa20eead58f0f5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MzE2OjI5RjJBRToxOEE4MDFEOjIxOUQ5RkM6Njk3MzQ0RjYiLCJ2aXNpdG9yX2lkIjoiNjgwMDQ1NzMyMTk1Njk4NDA1NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | e02b0270e29a4017b65a6219680651e415947c0a29adfff806f79275ab3f95d6 |
| hovercard-subject-tag | issue:2080491784 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/bethrobson/Head-First-JavaScript-Programming/27/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f672835b19a1b9f692f0858fee601ce6eb2c3ab02f376138bab51fb8e063e236/bethrobson/Head-First-JavaScript-Programming/issues/27 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f672835b19a1b9f692f0858fee601ce6eb2c3ab02f376138bab51fb8e063e236/bethrobson/Head-First-JavaScript-Programming/issues/27 |
| og:image:alt | Hello everyone! I've got a question about the final version of the code in Chapter 4 (root: Chapter 4 -> bubbles2.html). The function getMostCostEffectiveSolution(scores, costs, highScore) is meant... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Dexter1996777 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 574266c5e0389fb19fcea86ddb6d5b0008f148ada57d7a37ec4c90a19caee8f6 |
| turbo-cache-control | no-preview |
| go-import | github.com/bethrobson/Head-First-JavaScript-Programming git https://github.com/bethrobson/Head-First-JavaScript-Programming.git |
| octolytics-dimension-user_id | 30760 |
| octolytics-dimension-user_login | bethrobson |
| octolytics-dimension-repository_id | 8868903 |
| octolytics-dimension-repository_nwo | bethrobson/Head-First-JavaScript-Programming |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 8868903 |
| octolytics-dimension-repository_network_root_nwo | bethrobson/Head-First-JavaScript-Programming |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 3c64ddf9c1ec6ebf99c7b6faf0c61676d36f64c0 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width