René's URL Explorer Experiment


Title: Chapter 8 - Battleship game. · Issue #26 · bethrobson/Head-First-JavaScript-Programming · GitHub

Open Graph Title: Chapter 8 - Battleship game. · Issue #26 · bethrobson/Head-First-JavaScript-Programming

X Title: Chapter 8 - Battleship game. · Issue #26 · bethrobson/Head-First-JavaScript-Programming

Description: I am trying to hard code the ships and try to hit and sunk them, but the message that Ships were either, hit, or sunk, or were missed is not displaying on the webpage. Instead, it's displaying as Ships were sank all the time on top. I ch...

Open Graph Description: I am trying to hard code the ships and try to hit and sunk them, but the message that Ships were either, hit, or sunk, or were missed is not displaying on the webpage. Instead, it's displaying as S...

X Description: I am trying to hard code the ships and try to hit and sunk them, but the message that Ships were either, hit, or sunk, or were missed is not displaying on the webpage. Instead, it's displaying ...

Opengraph URL: https://github.com/bethrobson/Head-First-JavaScript-Programming/issues/26

X: @github

direct link

Domain: patch-diff.githubusercontent.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Chapter 8 - Battleship game.  ","articleBody":"I am trying to hard code the ships and try to hit and sunk them, but the message that Ships were either, hit, or sunk, or were missed is not displaying on the webpage. Instead, it's displaying as Ships were sank all the time on top. I checked the console for Errors, and there were none. I don't know what's wrong in my code.  \r\n\r\nSo far my code looks like this. And the console is not showing any errors.\r\n\r\n```\r\n\r\n\r\nvar view = { \r\ndisplayMessage: function(msg){\r\n\tvar messageArea = document.getElementById(\"messageArea\");\r\n\tmessageArea.innerHTML = msg;\r\n},\r\ndisplayHit: function(location){\r\n\tvar cell = document.getElementById(location);\r\n\tcell.setAttribute(\"class\",\"hit\");\r\n},\r\ndisplayMiss: function(location){\r\n\tvar cell = document.getElementById(location);\r\n\tcell.setAttribute(\"class\",\"miss\");\r\n}\r\n\r\n};\r\n\r\n\r\nview.displayMiss(\"00\");\r\nview.displayHit(\"34\");\r\nview.displayHit(\"12\");\r\nview.displayMiss(\"25\");\r\n\r\nview.displayMessage(\"are you on?\");\r\n\r\nvar model = {\r\n\tboardsize: 7,\r\n\tnumships: 3,\r\n\tshipLength: 3,\r\n\tshipSunk: 0,\r\n ships: [{ locations: [\"06\", \"16\", \"26\"], hits: [\"hit\", \"\", \"\"] },\r\n { locations: [\"24\", \"34\", \"44\"], hits: [\"\", \"\", \"\"] },\r\n { locations: [\"10\", \"11\", \"12\"], hits: [\"\", \"\", \"\"] }],\r\nfire: function(guess) {\r\n\tfor(var i = 0; i \u003c this.numships; i++){\r\n\t\tvar ship = this.ships[i];\r\n\t\tvar index = ship.locations.indexOf(guess);\r\n\t\tif(index \u003e=0){\r\n\t\t\tship.hits[index] = \"hit\";\r\n\t\t\tview.displayHit(guess);\r\n\t\t\tview.displayMessage(\"HIT!\");\r\n\t\t\tif (this.isSunk(ship)){\r\n\t\t\t\tview.displayMessage(\"You sank my warship\");\r\n\t\t\t\tthis.shipSunk++;\r\n\t\t\t}\r\n\t\t\treturn true;\r\n\t\t}\r\n\t}\r\n\tview.displayMiss(guess);\r\n\tview.displayMessage(\"You Missed.\");\r\n\treturn false;\r\n\t\r\n\t},\r\n\tisSunk: function(ship) {\r\n\t\tfor (var i = 0; i \u003c this.shipLength; i++){\r\n\t\t\tif (ship.hits[i] !== \"hit\"){\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn true;\r\n\r\n\t}\r\n};\r\n/*\r\nmodel.fire(\"53\");\r\nmodel.fire(\"06\");\r\nmodel.fire(\"16\");\r\nmodel.fire(\"26\");\r\nmodel.fire(\"34\");\r\nmodel.fire(\"24\");\r\nmodel.fire(\"44\");\r\nmodel.fire(\"12\");\r\nmodel.fire(\"11\");\r\nmodel.fire(\"10\");\r\n*/\r\nfunction parseGuess(guess){\r\n\tvar alphabet = [\"A\",\"B\",\"C\",\"D\",\"E\",\"F\",\"G\"];\r\n\tif(guess === null || guess.length !== 2){\r\n\t\talert(\"Enter a valid number and letter\");\r\n\t\t} else{\r\n\t\t\tvar row = alphabet.indexOf(guess.charAt(0));\r\n\t\t\tvar column = guess.charAt(1);\r\n\t\t\t\r\n\t\t\tif (isNaN(row) || isNaN(column)){\r\n\t\t\talert(\"invalid number\");\r\n\t\t\t}\r\n\t\t\telse if (row \u003c 0 || row \u003e= model.boardsize || column \u003c 0 || column \u003e= model.boardsize){\r\n\t\t\t\talert(\"off the board\");\r\n\t\t} else {\r\n\t\t\treturn row + column;\r\n\t\t}\r\n\r\n\t\t}\r\n\t\treturn null;\r\n\t\t}\r\n\t\r\nvar controller = {\r\n\tguesses: 0,\r\n\tprocessGuess: function(guess){\r\n\t\tvar location = parseGuess(guess);\r\n\t\tif(location){\r\n\t\t\tthis.guesses++;\r\n\t\t\tvar hit = model.fire(location);\r\n\t\t\tif(hit \u0026\u0026 model.shipSunk === model.numships) {\r\n\t\t\t\tview.displayMessage(\"You sank the warship, in\" + this.guesses + \"guesses\");\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\ncontroller.processGuess(\"A0\");\r\ncontroller.processGuess(\"A6\");\r\ncontroller.processGuess(\"B6\");\r\ncontroller.processGuess(\"C6\");\r\ncontroller.processGuess(\"C4\");\r\ncontroller.processGuess(\"D5\");\r\ncontroller.processGuess(\"E4\");\r\ncontroller.processGuess(\"B0\");\r\ncontroller.processGuess(\"B1\");\r\ncontroller.processGuess(\"B2\");\r\n\r\nfunction init(){\r\n\tvar fireButton = document.getElementById(\"fireButton\");\r\n\tfireButton.onclick = handleFireButton;\r\n\tguessInput.onkeypress = handleKeyPress;\r\n}\r\n\t\r\n\tfunction handleKeyPress(e){\r\n\t\tvar fireButton = document.getElementById(\"fireButton\");\r\n\t\tif(e.keycode === 13){\r\n\t\t\tfireButton.click();\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\tfunction handleFireButton(){\r\n\t\tvar guessInput = document.getElementById(\"guessInput\");\r\n\t\tvar guess = guessInput.value;\r\n\t\tcontroller.processGuess(guess);\r\n\t\tguessInput.value = \"\";\r\n\t}\r\n\twindow.onload = init;\r\n\r\n```\r\n\r\n \r\n \r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n \r\n```","author":{"url":"https://github.com/KU740","@type":"Person","name":"KU740"},"datePublished":"2020-10-09T13:32:12.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/26/Head-First-JavaScript-Programming/issues/26"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:6f184156-50ca-f0c4-2953-05227efbd395
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idC864:2B8087:7DFA4C:A917FF:697314C7
html-safe-nonce728390cd7324c4c78c7d0690b17205f42ce9640d275c2ee1915b09b181a1baee
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDODY0OjJCODA4Nzo3REZBNEM6QTkxN0ZGOjY5NzMxNEM3IiwidmlzaXRvcl9pZCI6IjQ5MDkyNjU5NjQ2MjYwMjM2MjMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacaadf2dc6b67268c0eb110bba0ab93244cd63d5f8661b894a7e078d7b52acc99b
hovercard-subject-tagissue:718149368
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/bethrobson/Head-First-JavaScript-Programming/26/issue_layout
twitter:imagehttps://opengraph.githubassets.com/2f8197a02e64e7a3df386311738d8a83bba5c4bd47690da53a4e652dafafa525/bethrobson/Head-First-JavaScript-Programming/issues/26
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/2f8197a02e64e7a3df386311738d8a83bba5c4bd47690da53a4e652dafafa525/bethrobson/Head-First-JavaScript-Programming/issues/26
og:image:altI am trying to hard code the ships and try to hit and sunk them, but the message that Ships were either, hit, or sunk, or were missed is not displaying on the webpage. Instead, it's displaying as S...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameKU740
hostnamegithub.com
expected-hostnamegithub.com
None44ab3188c1dcfe3be0f9c3feca2e04e14fb79f120939ce2395e4f15ab96ec1d4
turbo-cache-controlno-preview
go-importgithub.com/bethrobson/Head-First-JavaScript-Programming git https://github.com/bethrobson/Head-First-JavaScript-Programming.git
octolytics-dimension-user_id30760
octolytics-dimension-user_loginbethrobson
octolytics-dimension-repository_id8868903
octolytics-dimension-repository_nwobethrobson/Head-First-JavaScript-Programming
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id8868903
octolytics-dimension-repository_network_root_nwobethrobson/Head-First-JavaScript-Programming
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasea5e2b48bd1260476599758f5d253b5d24092ab84
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://patch-diff.githubusercontent.com/bethrobson/Head-First-JavaScript-Programming/issues/26#start-of-content
https://patch-diff.githubusercontent.com/
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Fbethrobson%2FHead-First-JavaScript-Programming%2Fissues%2F26
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Fbethrobson%2FHead-First-JavaScript-Programming%2Fissues%2F26
Sign up https://patch-diff.githubusercontent.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=bethrobson%2FHead-First-JavaScript-Programming
Reloadhttps://patch-diff.githubusercontent.com/bethrobson/Head-First-JavaScript-Programming/issues/26
Reloadhttps://patch-diff.githubusercontent.com/bethrobson/Head-First-JavaScript-Programming/issues/26
Reloadhttps://patch-diff.githubusercontent.com/bethrobson/Head-First-JavaScript-Programming/issues/26
bethrobson https://patch-diff.githubusercontent.com/bethrobson
Head-First-JavaScript-Programminghttps://patch-diff.githubusercontent.com/bethrobson/Head-First-JavaScript-Programming
Notifications https://patch-diff.githubusercontent.com/login?return_to=%2Fbethrobson%2FHead-First-JavaScript-Programming
Fork 341 https://patch-diff.githubusercontent.com/login?return_to=%2Fbethrobson%2FHead-First-JavaScript-Programming
Star 427 https://patch-diff.githubusercontent.com/login?return_to=%2Fbethrobson%2FHead-First-JavaScript-Programming
Code https://patch-diff.githubusercontent.com/bethrobson/Head-First-JavaScript-Programming
Issues 18 https://patch-diff.githubusercontent.com/bethrobson/Head-First-JavaScript-Programming/issues
Pull requests 4 https://patch-diff.githubusercontent.com/bethrobson/Head-First-JavaScript-Programming/pulls
Actions https://patch-diff.githubusercontent.com/bethrobson/Head-First-JavaScript-Programming/actions
Projects 0 https://patch-diff.githubusercontent.com/bethrobson/Head-First-JavaScript-Programming/projects
Wiki https://patch-diff.githubusercontent.com/bethrobson/Head-First-JavaScript-Programming/wiki
Security 0 https://patch-diff.githubusercontent.com/bethrobson/Head-First-JavaScript-Programming/security
Insights https://patch-diff.githubusercontent.com/bethrobson/Head-First-JavaScript-Programming/pulse
Code https://patch-diff.githubusercontent.com/bethrobson/Head-First-JavaScript-Programming
Issues https://patch-diff.githubusercontent.com/bethrobson/Head-First-JavaScript-Programming/issues
Pull requests https://patch-diff.githubusercontent.com/bethrobson/Head-First-JavaScript-Programming/pulls
Actions https://patch-diff.githubusercontent.com/bethrobson/Head-First-JavaScript-Programming/actions
Projects https://patch-diff.githubusercontent.com/bethrobson/Head-First-JavaScript-Programming/projects
Wiki https://patch-diff.githubusercontent.com/bethrobson/Head-First-JavaScript-Programming/wiki
Security https://patch-diff.githubusercontent.com/bethrobson/Head-First-JavaScript-Programming/security
Insights https://patch-diff.githubusercontent.com/bethrobson/Head-First-JavaScript-Programming/pulse
New issuehttps://patch-diff.githubusercontent.com/login?return_to=https://github.com/bethrobson/Head-First-JavaScript-Programming/issues/26
New issuehttps://patch-diff.githubusercontent.com/login?return_to=https://github.com/bethrobson/Head-First-JavaScript-Programming/issues/26
Chapter 8 - Battleship game. https://patch-diff.githubusercontent.com/bethrobson/Head-First-JavaScript-Programming/issues/26#top
https://github.com/KU740
https://github.com/KU740
KU740https://github.com/KU740
on Oct 9, 2020https://github.com/bethrobson/Head-First-JavaScript-Programming/issues/26#issue-718149368
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.