{"id":21553296,"url":"https://github.com/alizayayesha/javascript-assignment-2","last_synced_at":"2025-04-30T09:48:39.917Z","repository":{"id":228120966,"uuid":"773148042","full_name":"AlizayAyesha/JavaScript-assignment-2","owner":"AlizayAyesha","description":"15 short task for practice js ","archived":false,"fork":false,"pushed_at":"2024-03-28T01:57:26.000Z","size":9,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-24T10:08:06.606Z","etag":null,"topics":["100daysofcode","practice-javascript","practice-programming","practice-project"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/AlizayAyesha.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":"2024-03-16T21:57:18.000Z","updated_at":"2024-08-12T21:40:02.000Z","dependencies_parsed_at":"2024-03-28T02:36:04.659Z","dependency_job_id":"1b779629-8e66-41b2-b0d9-17d62bfcc37c","html_url":"https://github.com/AlizayAyesha/JavaScript-assignment-2","commit_stats":null,"previous_names":["alizayayesha/js-assigment-1","alizayayesha/javascript-assignment-2"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlizayAyesha%2FJavaScript-assignment-2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlizayAyesha%2FJavaScript-assignment-2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlizayAyesha%2FJavaScript-assignment-2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlizayAyesha%2FJavaScript-assignment-2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AlizayAyesha","download_url":"https://codeload.github.com/AlizayAyesha/JavaScript-assignment-2/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235418850,"owners_count":18987135,"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":["100daysofcode","practice-javascript","practice-programming","practice-project"],"created_at":"2024-11-24T07:10:08.914Z","updated_at":"2025-01-24T10:08:12.422Z","avatar_url":"https://github.com/AlizayAyesha.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# js-assigment-1\n-------------------------------------------------------------\n**Note: Check Rules end of document**\n\n**1. Write a script to display the following message on your web page:\n(Hint : Use line break)**\n\n**index.html**\n\n\u003chtml\u003e\n    \u003ctitle\u003eJs sample\u003c/title\u003e\n    \u003cscript src=\" index.js\"\u003e\u003c/script\u003e\n    \u003chead\u003e\n        \u003cbody\u003e\n            \n        \u003c/body\u003e\n    \u003c/head\u003e\n\u003c/html\u003e\n\n**index.js**\n\nalert(\"Welcome To Js Land...\\n Happy Coding!\")\n\n![image](https://github.com/AlizayAyesha/js-assigment-1/assets/68489612/6eaa03a5-f1ef-462d-8722-25bf72b0650f)\n\n-------------------------------------------------------------\n\n**2. Write a script to save student’s bio data in JS variables and show the\ndata in alert boxes.**\n\n**index.html**\n\n\u003chtml\u003e\n    \u003ctitle\u003eJs sample\u003c/title\u003e\n    \u003cscript src=\" index.js\"\u003e\u003c/script\u003e\n    \u003chead\u003e\n        \u003cbody\u003e\n            \n        \u003c/body\u003e\n    \u003c/head\u003e\n\u003c/html\u003e\n\n**index.js**\n\nvar a = \"Alizay\"\n\nvar b =\" 21 years old\"\n\nvar c = \"Certified Mobile Application Development\"\n\nalert(a)\nalert(b)\nalert(c)\n\n![image](https://github.com/AlizayAyesha/js-assigment-1/assets/68489612/67cf20c6-7282-4c61-827c-1765ee416b32)\n![image](https://github.com/AlizayAyesha/js-assigment-1/assets/68489612/1c239d6a-59fd-4612-86ac-16e1f2a6754e)\n![image](https://github.com/AlizayAyesha/js-assigment-1/assets/68489612/4c47aa27-4045-4b3e-9b56-3c9263efb2a8)\n\n-------------------------------------------------------------\n\n**3. Declare a variable called email and assign to it a string that\nrepresents your Email Address(e.g. example@example.com). Show\nthe below mentioned message in an alert box.(Hint: use string\nconcatenation)**\n\n**index.html**\n\n\u003chtml\u003e\n    \u003ctitle\u003eJs sample\u003c/title\u003e\n    \u003cscript src=\" index.js\"\u003e\u003c/script\u003e\n    \u003chead\u003e\n        \u003cbody\u003e\n            \n        \u003c/body\u003e\n    \u003c/head\u003e\n\u003c/html\u003e\n\n\n**index.js**\n\nvar email = \"My Email address is sherlockholme898@gmail.com\"\nalert(email)\nconsole.log(email)\n![image](https://github.com/AlizayAyesha/js-assigment-1/assets/68489612/e4e86740-adcf-48d3-83dd-74c700d1c1f6)\n\n-------------------------------------------------------------\n**4. Write a script to display this in browser through JS**\n\n**index.html**\n\n\u003chtml\u003e\n    \u003ctitle\u003eJs sample\u003c/title\u003e\n    \u003cscript src=\" index.js\"\u003e\u003c/script\u003e\n    \u003chead\u003e\n        \u003cbody\u003e\n            Hello ! \u003cbr\u003e\n            How are you? \u003cbr\u003e\n            Yah! I can write HTML content through JavaScript\n        \u003c/body\u003e\n    \u003c/head\u003e\n\u003c/html\u003e\n![image](https://github.com/AlizayAyesha/js-assigment-1/assets/68489612/08e245ab-346f-41ac-b934-f15ddd00a662)\n\n-------------------------------------------------------------\n**5. Declare a variable called age \u0026 assign to it your age. Show your age\nin an alert box.**\n\n**index.html**\n\n\u003chtml\u003e\n    \u003ctitle\u003eJs sample\u003c/title\u003e\n    \u003cscript src=\" index.js\"\u003e\u003c/script\u003e\n    \u003chead\u003e\n        \u003cbody\u003e\n\n        \u003c/body\u003e\n    \u003c/head\u003e\n\u003c/html\u003e\n\n**inex.js**\n\nalert(\"I am 21 years old\")\n\n\n![image](https://github.com/AlizayAyesha/js-assigment-1/assets/68489612/837b0869-251d-4f33-86e0-81879d817e3c)\n-------------------------------------------------------------\n\n**6. Declare a variable called birthYear \u0026 assign to it your birth year.\nShow the following message in your browser:**\n\n**index.html**\n\n\u003chtml\u003e\n    \u003ctitle\u003eJs sample\u003c/title\u003e\n    \u003cscript src=\" index.js\"\u003e\u003c/script\u003e\n    \u003chead\u003e\n        \u003cbody\u003e\nMy Birth Year is 2003 \u003cbr\u003e\ndata type of my decleared variable is number\n        \u003c/body\u003e\n    \u003c/head\u003e\n\u003c/html\u003e\n\n![image](https://github.com/AlizayAyesha/js-assigment-1/assets/68489612/1a7bb484-f5b4-4e4b-bc5a-e816807b5cab)\n\n-------------------------------------------------------------\n\n**7. Display this in your browser\na. A heading stating “Rules for naming JS variables”\nb. Variable names can only contain ______, ______,\nc. ______ and ______.\nd. For example $my_1stVariable.\ne. Variables must begin with a ______, ______ or\nf. _____. For example $name, _name or name\ng. Variable names are case _________\nh. Variable names should not be JS _________**\n\n\n**index.html**\n\n\u003chtml\u003e\n    \u003ctitle\u003eJs sample\u003c/title\u003e\n    \u003cscript src=\" index.js\"\u003e\u003c/script\u003e\n    \u003chead\u003e\n        \u003cbody\u003e\n            \n\u003ch1\u003eRules For Naming variables in JavaScript\u003c/h1\u003e\n\n\u003cb\u003e1-\u003c/b\u003e Variable names can only contain a letter, an underscore ( _ ) or a dollar sign ( $ ) and\nVariable names cannot contain spaces.\u003cbr\u003e\n\u003cb\u003eFor example : $my_1stVariable.\u003c/b\u003e \u003cbr\u003e\n\u003cb\u003e2-\u003c/b\u003e Variables must begin with a  a letter or an underscore character (_) A variable name cannot start with a digit. A variable name can only contain alpha-numeric characters and underscores ( a-z, A-Z , \n0-9 , and _ ) Variable names are case-sensitive (age, Age and AGE are three different variables) \u003cbr\u003e\n\u003cb\u003eFor example : $name, _name or name\u003c/b\u003e\u003cbr\u003e\n\u003cb\u003e3-\u003c/b\u003e Variable names are case sensitive. \u003cbr\u003e\n\u003cb\u003eFor example, the while keywords must be typed “while”, not “While” or “WHILE”\u003c/b\u003e \u003cbr\u003e\n\u003cb\u003e4-\u003c/b\u003e Variable names should not be JS keyword \u003cbr\u003e\n\u003cb\u003eFor example it cannot be the same as reserved keywords such as if or const it can only process camelCase e.g (e.g. sellingPrice and costPrice rather than x and y )\u003c/b\u003e\n\n        \u003c/body\u003e\n    \u003c/head\u003e\n\u003c/html\u003e\n\n![image](https://github.com/AlizayAyesha/js-assigment-1/assets/68489612/66ab70ce-c237-4c78-b25a-d6db13933a6e)\n\n-------------------------------------------------------------\n\n**8. Write a program that takes two numbers \u0026 add them in a new\nvariable. Show the result in your browser.**\n\n**index.html**\n\n\u003chtml\u003e\n    \u003ctitle\u003eJs sample\u003c/title\u003e\n    \u003cscript src=\" index.js\"\u003e\u003c/script\u003e\n    \u003chead\u003e\n        \u003cbody\u003e\n            \u003cb\u003eSum of a and b is 4\u003c/b\u003e\n        \u003c/body\u003e\n    \u003c/head\u003e\n\u003c/html\u003e\n\n**index.js**\n\n\nvar a = 1\nvar b = 3\n\nconsole.log(a + b )\n\n![image](https://github.com/AlizayAyesha/js-assigment-1/assets/68489612/bdbc1d27-6899-4973-a7e9-a5eb7bba0ca9)\n\n-------------------------------------------------------------\n\n**9. Repeat task 8 for subtraction, multiplication, division \u0026 modulus.**\n\n**index.html**\n\n\u003chtml\u003e\n    \u003ctitle\u003eJs sample\u003c/title\u003e\n    \u003cscript src=\" index.js\"\u003e\u003c/script\u003e\n    \u003chead\u003e\n        \u003cbody\u003e\n            \u003cb\u003ea = 1\u003cbr\u003e\n            b = 2 \u003cbr\u003e\n c = sum of a + b is  3\u003cbr\u003e\n d = sum of a - b is -1\u003cbr\u003e\n e = sum of a * b is  2\u003cbr\u003e\n f = sum of a % b is  1\u003cbr\u003e\n g = sum of a / b is  0.5\u003cbr\u003e\n h = sum of a ** b is 1\u003cbr\u003e\n\n        \u003c/b\u003e\n        \u003c/body\u003e\n    \u003c/head\u003e\n\u003c/html\u003e\n\n**index.js**\n\nvar a = 1\nvar b = 2\nvar c = a + b //add result 3\nvar d = a - b //sub result 1\nvar e = a * b //mul result 2\nvar f = a % b //module result 1\nvar g = a / b //division result 0.5\nvar h = a ** b //exponentiation result 1\n\nconsole.log(c)\nconsole.log(d)\nconsole.log(e)\nconsole.log(f)\nconsole.log(g)\nconsole.log(h)\n\n![image](https://github.com/AlizayAyesha/js-assigment-1/assets/68489612/1f9876c1-c898-4698-9842-2247a6a5f367)\n\n-------------------------------------------------------------\n\n**10. Do the following using JS Mathematic Expressions\na. Declare a variable.\nb. Show the value of variable in your browser like “Value after\nvariable declaration is: ??”.\nc. Initialize the variable with some number.\nd. Show the value of variable in your browser like “Initial value: 5”.\ne. Increment the variable.\nf. Show the value of variable in your browser like “Value after\nincrement is: 6”.\ng. Add 7 to the variable.\nh. Show the value of variable in your browser like “Value after\naddition is: 13”.\ni. Decrement the variable.\nj. Show the value of variable in your browser like “Value after\ndecrement is: 12”.\nk. Show the remainder after dividing the variable’s value by 3.\nl. Output : “The remainder is : 0”.**\n\n**index.html**\n\u003chtml\u003e\n    \u003ctitle\u003eJs sample\u003c/title\u003e\n    \u003cscript src=\" index.js\"\u003e\u003c/script\u003e\n    \u003chead\u003e\n        \u003cbody\u003e\n            Value after variable declaration is undefined \u003cbr\u003e\n            \u003cb\u003eInitializing the variable with some number.\u003c/b\u003e \u003cbr\u003e\nInitial value : 5\u003cbr\u003e\n\u003cb\u003eIncrement the variable.\u003c/b\u003e \u003cbr\u003e\nValue after\nincrement is: 6\u003cbr\u003e\n\u003cb\u003eAdd 7 to the variable.\u003c/b\u003e \u003cbr\u003e\nValue after\naddition is :13\u003cbr\u003e\n\u003cb\u003eDecrement the variable.\u003c/b\u003e \u003cbr\u003e\nValue after\ndecrement is: 12\u003cbr\u003e \n\u003cb\u003eRemainder\u003c/b\u003e \u003cbr\u003e\nOutput : “The remainder is : 0”.\n\n\n\n        \u003c/body\u003e\n    \u003c/head\u003e\n\u003c/html\u003e\n\n**index.js**\n\nvar value1\nconsole.log(value1)\nvar value2 = 5\nconsole.log(value2)\nvar value3 = value2++\nconsole.log(value2)\nvar value4 = value2 + 7\nconsole.log(value4)\nvar value5 = --value4\nconsole.log(value5)\nvar value6 = value5 / 3\nconsole.log(value6) \n\n![image](https://github.com/AlizayAyesha/js-assigment-1/assets/68489612/84cf446c-6d7f-4a3c-aa3f-574f4d38097b)\n\n-------------------------------------------------------------\n**11. The Temperature Converter: It’s hot out! Let’s make a converter\nbased on the steps here.\na. Store a Celsius temperature into a variable.\nb. Convert it to Fahrenheit \u0026 output “N\noC is N\noF”.\nc. Now store a Fahrenheit temperature into a variable.\nd. Convert it to Celsius \u0026 output “N\noF is N\noC”.\n\nConversion Formulae**\n\n**index.html**\n\n\u003chtml\u003e\n    \u003ctitle\u003eJs sample\u003c/title\u003e\n    \u003cscript src=\" index.js\"\u003e\u003c/script\u003e\n    \u003chead\u003e\n        \u003cbody\u003e\n            30Â°C is 86Â°F \u003cbr\u003e\n            \n          86Â°F is 30Â°C\n        \u003c/body\u003e\n    \u003c/head\u003e\n\u003c/html\u003e\n\n**index.js**\n\nvar celsius = 30;\nvar fahrenheit = (celsius * 9/5) + 32;\nconsole.log(celsius + \"°C is \" + fahrenheit + \"°F\");\n\nvar fahrenheit2 = 86;\nvar celsius2 = (fahrenheit2 - 32) * 5/9;\nconsole.log(fahrenheit2 + \"°F is \" + celsius2 + \"°C\");\n\n![image](https://github.com/AlizayAyesha/js-assigment-1/assets/68489612/d1c591c3-4689-4284-b222-4f139da8f60a)\n\n-------------------------------------------------------------\n**12. Assume we have 10 US dollars \u0026 25 Saudi Riyals. Write a script to\nconvert the total currency to Pakistani Rupees. Perform all\ncalculations in a single expression. (Exchange rates : 1 US Dollar =\n155 Pakistani Rupee and 1 Saudi Riyal = 41 Pakistani Rupee)**\n\n\n**index.html**\n\n\u003chtml\u003e\n    \u003ctitle\u003eJs sample\u003c/title\u003e\n    \u003cscript src=\" index.js\"\u003e\u003c/script\u003e\n    \u003chead\u003e\n        \u003cbody\u003e\n\u003cb\u003eCurrency in PKR\u003c/b\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\nTotal Currency in PKR : 2,575\n        \u003c/body\u003e\n    \u003c/head\u003e\n\u003c/html\u003e\n\n**index.js**\n\nvar us_dollar = 10\nconsole.log(us_dollar)\nvar saudi_riyal = 25\nconsole.log(saudi_riyal)\n\nvar usd_to_pkr = 155\nconsole.log(usd_to_pkr)\nvar sar_to_pkr = 41\nconsole.log(sar_to_pkr)\n\nvar totalPkr = (us_dollar * usd_to_pkr) + (saudi_riyal * sar_to_pkr)\nconsole.log(totalPkr)\n\n![image](https://github.com/AlizayAyesha/js-assigment-1/assets/68489612/7f759408-297e-4002-abe3-1cfc3fb931df)\n\n\n-------------------------------------------------------------\n\n**13. Write a program to take a number in a variable, do the required\narithmetic to display the following result in your browser:**\n\n**index.html**\n\n\u003chtml\u003e\n    \u003ctitle\u003eJs sample\u003c/title\u003e\n    \u003cscript src=\" index.js\"\u003e\u003c/script\u003e\n    \u003chead\u003e\n        \u003cbody\u003e\n   \u003ch\u003eResult:\n   \u003c/h\u003e \u003cbr\u003e\n   The value of 'a' is 10 \u003cbr\u003e\n   ----------------------\u003cbr\u003e\n   \u003cbr\u003e\n   The value of '++a' is : 11 \u003cbr\u003e\n   Now the of 'a' is : 11 \u003cbr\u003e\n   \u003cbr\u003e\n   \u003cbr\u003e\n   The value of 'a++' is : 11\u003cbr\u003e\n   Now the value of 'a' is : 12\u003cbr\u003e\n   \u003cbr\u003e\n   \u003cbr\u003e\n   The value of '--a' is : 11\u003cbr\u003e\n   Now the value of 'a' is :11\u003cbr\u003e\n   \u003cbr\u003e\n   \u003cbr\u003e\n   The value of 'a--' is : 11\u003cbr\u003e\n   Now the value of 'a' is : 10 \u003cbr\u003e\n\n\n\n\n        \u003c/body\u003e\n    \u003c/head\u003e\n\u003c/html\u003e\n\n\n**index.js**\n\nvar a = 10\nconsole.log(a)\n\nvar b = ++a\nconsole.log(b)\n\nvar a = 11\nconsole.log(a)\n\nvar c = a++\nconsole.log(c)\n\nvar a = 12\nconsole.log(a)\n\nvar d = --a;\nconsole.log(d)\n\nvar a = 11\nconsole.log(a)\n\nvar e =  a--\nconsole.log(e)\n\nvar a = 10\nconsole.log(a)\n\n![image](https://github.com/AlizayAyesha/js-assigment-1/assets/68489612/5d1c8aee-3054-4680-a36e-0f44ffba7f1d)\n\n-------------------------------------------------------------\n\n**14. What will be the output in variables a, b \u0026 result after execution of\nthe following script:\nvar a = 2, b = 1;\nvar result = --a - --b + ++b + b--;\nExplain the output at each stage:\n--a;\n--a - --b;\n--a - --b + ++b;\n--a - --b + ++b + b--;**\n\n**index.html**\n\n\u003chtml\u003e\n    \u003ctitle\u003eJs sample\u003c/title\u003e\n    \u003cscript src=\" index.js\"\u003e\u003c/script\u003e\n    \u003chead\u003e\n        \u003cbody\u003e\n   a = 2 \u003cbr\u003e\n   b = 1 \u003cbr\u003e\n   result = 3\n        \u003c/body\u003e\n    \u003c/head\u003e\n\u003c/html\u003e\n\n**index.js**\n\nvar a = 2, b = 1;\nconsole.log(a)\nvar result = --a - --b + ++b + b--;\nconsole.log(result)\n\n\n![image](https://github.com/AlizayAyesha/js-assigment-1/assets/68489612/98df9b1a-0681-4d11-bf04-47dc620d5ee7)\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falizayayesha%2Fjavascript-assignment-2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falizayayesha%2Fjavascript-assignment-2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falizayayesha%2Fjavascript-assignment-2/lists"}