{"id":26871210,"url":"https://github.com/codeadamca/javascript-output","last_synced_at":"2025-03-31T07:18:47.497Z","repository":{"id":46327657,"uuid":"329102034","full_name":"codeadamca/javascript-output","owner":"codeadamca","description":"A basic example of using JavaScript to create output.","archived":false,"fork":false,"pushed_at":"2025-01-26T22:08:28.000Z","size":249,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-26T23:18:43.624Z","etag":null,"topics":["javascript","learning-code","output"],"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}},"created_at":"2021-01-12T20:18:51.000Z","updated_at":"2025-01-26T22:08:31.000Z","dependencies_parsed_at":"2025-01-26T23:28:23.589Z","dependency_job_id":null,"html_url":"https://github.com/codeadamca/javascript-output","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeadamca%2Fjavascript-output","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeadamca%2Fjavascript-output/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeadamca%2Fjavascript-output/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeadamca%2Fjavascript-output/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codeadamca","download_url":"https://codeload.github.com/codeadamca/javascript-output/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246429487,"owners_count":20775809,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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","output"],"created_at":"2025-03-31T07:18:47.014Z","updated_at":"2025-03-31T07:18:47.490Z","avatar_url":"https://github.com/codeadamca.png","language":"HTML","readme":"# A Basic Introduction to JavaScript and Output\n\nJavaScript can be used to create output. This can be done many different ways:\n\n- Using `document.write` to add content to the HTML webpage\n- Use `alert()` to display a warning message in an alert popup\n- Use `console.log()` to display a message in the developer tools of a browser\n\n## Using `document.write`\n\nThe `document.write` command will add content to the document. \n\nOpen up a new HTML file, name it output.html, add the standard HTML elements, and then add the following code:\n\n```html\n\u003cscript\u003e\ndocument.write( \"\u003ch1\u003eCreating Output\u003c/h1\u003e\" );\ndocument.write( \"\u003cp\u003eQuotes can cause conflicts with creating output.\" + \" \" + \n    \"To resolve quote issues there are three solutions:\u003c/p\u003e\" );\ndocument.write( \"\u003cul\u003e\" + \n    \"\u003cli\u003eEscape them with a slash\u003c/li\u003e\" + \n    \"\u003cli\u003eUse alternating quotes\u003c/li\u003e\" + \n    \"\u003cli\u003eUse special characters\u003c/li\u003e\" + \n    \"\u003c/ul\u003e\" );\n\u003c/script\u003e\n```\n\nTest the file using a browser. The `body` section of the webpage should have some useful information regarding JavaScript, output, and quotations. \n\n## Using `alert`\n\nThe `alert()` command will display a message using an alert style popup. \n\nOpen up the previous file, right before the closing `script` tag, add the following code:\n\n```javascript\nalert(\"This is an alert message\");\n```\n\n## Using `console.log`\n\nThe `console.log()` command will display a message using the browser developer tools. \n\nOpen up the previous file, right before the closing `script` tag, add the following code:\n\n```javascript\nconsole.log( \"This is a console log\" );\n```\n\nTo test the `console.log` line of code, follow these steps:\n\n1. Open a browser\n2. Right click on the web page and choose Inspect Element\n3. From the developer tools, choose the Console tab\n3. Open the `output.html` file\n4. The message in the `console.log` command will be displayed\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\u003eCreating Output\u003c/title\u003e\n    \u003c/head\u003e\n    \u003cbody\u003e\n        \n        \u003ch1\u003eW3Schools\u003c/h1\u003e\n\n        \u003cp\u003eW3Schools is a web developer information website, with tutorials\n            and references relating to web development topics such as HTML, CSS,\n            JavaScript and PHP.\u003c/p\u003e\n\n        \u003ca href=\"http://www.w3schools.com/\"\u003eW3Schools\u003c/a\u003e\n\n        \u003cbr\u003e\n\n        \u003cimg src=\"w3schools.png\"\u003e\n\n    \u003c/body\u003e\n\u003c/html\u003e\n```\n\nConvert each line of HTML in the `body` section to use JavaScript and `document.write()`. For example, converting the `h1` element could 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\u003eCreating Output\u003c/title\u003e\n    \u003c/head\u003e\n    \u003cbody\u003e\n\n        \u003cscript\u003e\n\n        document.write(\"\u003ch1\u003eW3Schools\u003c/h1\u003e\");\n\n        \u003c/script\u003e\n\n        \u003cp\u003eW3Schools is a web developer information website, with tutorials\n            and references relating to web development topics such as HTML, CSS,\n            JavaScript and PHP.\u003c/p\u003e\n\n        \u003ca href=\"http://www.w3schools.com/\"\u003eW3Schools\u003c/a\u003e\n\n        \u003cbr\u003e\n\n        \u003cimg src=\"w3schools.png\"\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 and a number of `document.write()` commands. \n\n\u003e Full tutorial URL:  \n\u003e https://codeadam.ca/learning/javascript-output.html\n\n***\n\n## Repo Resourcecs\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","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeadamca%2Fjavascript-output","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodeadamca%2Fjavascript-output","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeadamca%2Fjavascript-output/lists"}