{"id":26871208,"url":"https://github.com/codeadamca/javascript-variables-arrays","last_synced_at":"2026-07-04T10:31:02.697Z","repository":{"id":46327715,"uuid":"329161869","full_name":"codeadamca/javascript-variables-arrays","owner":"codeadamca","description":"A basic example of using variables and arrays.","archived":false,"fork":false,"pushed_at":"2025-01-26T22:08:43.000Z","size":246,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-07T01:19:36.350Z","etag":null,"topics":["javascript","learning-code","variables"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codeadamca.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-01-13T01:42:30.000Z","updated_at":"2025-01-26T22:08:46.000Z","dependencies_parsed_at":"2025-01-26T23:28:23.590Z","dependency_job_id":null,"html_url":"https://github.com/codeadamca/javascript-variables-arrays","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/codeadamca/javascript-variables-arrays","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeadamca%2Fjavascript-variables-arrays","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeadamca%2Fjavascript-variables-arrays/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeadamca%2Fjavascript-variables-arrays/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeadamca%2Fjavascript-variables-arrays/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codeadamca","download_url":"https://codeload.github.com/codeadamca/javascript-variables-arrays/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeadamca%2Fjavascript-variables-arrays/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35118970,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-04T02:00:05.987Z","response_time":113,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","learning-code","variables"],"created_at":"2025-03-31T07:18:46.699Z","updated_at":"2026-07-04T10:31:02.674Z","avatar_url":"https://github.com/codeadamca.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# A Basic Introduction to JavaScript, Variables, and Arrays\n\nVariables and arrays are used to store data to use within your code. A variable can store one piece of data whle an array can store multiple values. \n\n## Using Variables\n\nTo create a variable use the `var`, `let`, or `const` commands.\n\nOpen up a new HTML file, name it variables.html, add the standard HTML elements, and then add the following code to the `body` tag:\n\n```html\n\u003cscript\u003e\n\nvar firstName = \"Peter\";\nvar lastName = \"Smith\";\n    \ndocument.write( \"\u003cp\u003eHello \" + firstName + \" \" + lastName + \"\u003c/p\u003e\" );\n\n\u003c/script\u003e\n```\n\nInside a `document.write()` command, text in between quotes is treated as plain text, while text outside of quotes is treated as a variable, array, or other JavaScript command.\n\nOpen the the file using a browser. The `body` section should include a greeting.\n\n## Trying it Out\n\nCreate an HTML file and add the following code:\n\n```html\n\u003c!doctype html\u003e\n\u003chtml\u003e\n    \u003chead\u003e\n        \u003cmeta charset=\"utf-8\"\u003e\n        \u003ctitle\u003eJavaScript Variables Exercise\u003c/title\u003e\n    \u003c/head\u003e\n    \u003cbody\u003e\n    \n        \u003cscript\u003e\n\n        var linkName = \"W3Schools\";\n        var linkLogo = \"w3schools.png\";\n        var linkURL = \"http://www.w3schools.com/\";\n        var linkDescription = \"W3Schools is a web developer information website, with tutorials and references relating to web development topics such as HTML, CSS, JavaScript and PHP.\";\n        \n        \u003c/script\u003e\n\n    \u003c/body\u003e\n\u003c/html\u003e\n```\n\nUse `document.write()` and the provided variables to display the link information using well formatted HTML. For example, the first variable may look like this:\n\n```html\n\u003c!doctype html\u003e\n\u003chtml\u003e\n    \u003chead\u003e\n        \u003cmeta charset=\"utf-8\"\u003e\n        \u003ctitle\u003eJavaScript Variables Exercise\u003c/title\u003e\n    \u003c/head\u003e\n    \u003cbody\u003e\n    \n        \u003cscript\u003e\n\n        var linkName = \"W3Schools\";\n        var linkLogo = \"w3schools.png\";\n        var linkURL = \"http://www.w3schools.com/\";\n        var linkDescription = \"W3Schools is a web developer information website, with tutorials and references relating to web development topics such as HTML, CSS, JavaScript and PHP.\";\n        \n        document.write(\"\u003ch1\u003e\" + linkName + \"\u003c/h1\u003e\");\n\n        \u003c/script\u003e\n\n    \u003c/body\u003e\n\u003c/html\u003e\n```\n\nWhen you have completed the goal, the `body` tag will only include one `script` tag, the four provided variables, and a number of document.write()` commands outputting the variables with HTML. \n\n## Varables and Math\n\nOpen up a new HTML file, name it variables.html, add the standard HTML elements, and then add the following code to the `body` tag:\n\n```html\n\u003cscript\u003e\n\nvar x = 5;\nvar y = 10;\n    \ndocument.write( \"\u003cp\u003eFive plus ten is \" + x + y + \"\u003c/p\u003e\" );\ndocument.write( \"\u003cp\u003eFive times ten is \" + x * y + \"\u003c/p\u003e\" );\n\n\u003c/script\u003e\n```\n\nOpen the the file using a browser. The `body` section should contain a series of math answers.\n\n## Using Arrays\n\nTo create an array, use the same syntax as a variable, except the type of variable with be an array:\n\n```javascript\nvar colours = new Array();\n```\n\nThen populate the array using keys:\n\n```javascript\ncolours[0] = 'Red';\ncolours[1] = 'Blue';\ncolours[2] = 'Green';\n```\n\nOutputting an array value is similar to outputting a variable, except the variable is followed by a key:\n\n```javascript\ndocument.write(\"\u003cp\u003eMy favourtie colour is \" + colours[0] + \".\u003c/p\u003e\");\n```\n\n## Trying it Out\n\nCreate an array list of items. Then use a series of `document.write()` commands to display the list.\n\n\u003e Full tutorial URL:  \n\u003e https://codeadam.ca/learning/javascript-variables-arrays.html\n\n***\n\n## Repo REsources\n\n* [Visual Studio Code](https://code.visualstudio.com/)\n\n\u003cbr\u003e\n\u003ca href=\"https://codeadam.ca\"\u003e\n\u003cimg src=\"https://cdn.codeadam.ca/images@1.0.0/codeadam-logo-coloured-horizontal.png\" width=\"200\"\u003e\n\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeadamca%2Fjavascript-variables-arrays","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodeadamca%2Fjavascript-variables-arrays","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeadamca%2Fjavascript-variables-arrays/lists"}