Feat/add guide article for javascript (#34007)
This commit is contained in:
committed by
Nishant Mishra
parent
cdb8d72db8
commit
bc879e14d2
@ -1,10 +1,30 @@
|
|||||||
---
|
---
|
||||||
title: Multiply Two Decimals with JavaScript
|
title: Multiply Two Decimals with JavaScript
|
||||||
---
|
---
|
||||||
|
|
||||||
## Multiply Two Decimals with JavaScript
|
## Multiply Two Decimals with JavaScript
|
||||||
|
JavaScript uses the `*` symbol for multiplication. Multiplying floats is the same as multiplying integers. JavaScript only has the *number* type, which serves both integer and floating point numbers, it does not have a specific type for integers.
|
||||||
|
|
||||||
This is a stub. <a href='https://github.com/freecodecamp/guides/tree/master/src/pages/certifications/javascript-algorithms-and-data-structures/basic-javascript/multiply-two-decimals-with-javascript/index.md' target='_blank' rel='nofollow'>Help our community expand it</a>.
|
For example, if you were to multiply 2 integers, the numbers 3 and 5, then you could simply type:
|
||||||
|
```javascript
|
||||||
|
var product = 3 * 5; // product is 15
|
||||||
|
```
|
||||||
|
Now if we were to multiply two floating point numbers, 3.4 and 5.7, the product would be a float as well:
|
||||||
|
```javascript
|
||||||
|
var product = 3.4 * 5.7; // product is 19.38
|
||||||
|
```
|
||||||
|
|
||||||
<a href='https://github.com/freecodecamp/guides/blob/master/README.md' target='_blank' rel='nofollow'>This quick style guide will help ensure your pull request gets accepted</a>.
|
### Hint 1
|
||||||
|
Think about what decimal number, when multiplied by 2.0, would equal 5.0.
|
||||||
|
|
||||||
<!-- The article goes here, in GitHub-flavored Markdown. Feel free to add YouTube videos, images, and CodePen/JSBin embeds -->
|
> *try to solve the problem now*
|
||||||
|
|
||||||
|
## Spoiler Alert!
|
||||||
|
__Solution Ahead!__
|
||||||
|
|
||||||
|
### Code Solution
|
||||||
|
```javascript
|
||||||
|
var product = 2.0 * 2.5; // product is 5.0 because 2.5 * 2.0 = 5.0
|
||||||
|
```
|
||||||
|
#### More Information
|
||||||
|
* [DigitalOcean - How to do Math in JavaScript with Operators](https://www.digitalocean.com/community/tutorials/how-to-do-math-in-javascript-with-operators)
|
||||||
|
@ -1,45 +1,49 @@
|
|||||||
---
|
---
|
||||||
title: Links
|
title: Links
|
||||||
---
|
---
|
||||||
|
|
||||||
## Links
|
## Links
|
||||||
|
|
||||||
This is a stub. <a href='https://github.com/freecodecamp/guides/tree/master/src/pages/html/attributes/links/index.md' target='_blank' rel='nofollow'>Help our community expand it</a>.
|
### <a id="link-top"></a> General Links
|
||||||
|
Links are used everywhere on the web, with the purpose of directing users to various content items. They're usually indicated by your cursor turning into a hand icon. Links can be text, images, or other elements contained within your HTML or webpage.
|
||||||
<a href='https://github.com/freecodecamp/guides/blob/master/README.md' target='_blank' rel='nofollow'>This quick style guide will help ensure your pull request gets accepted</a>.
|
|
||||||
|
|
||||||
<!-- The article goes here, in GitHub-flavored Markdown. Feel free to add YouTube videos, images, and CodePen/JSBin embeds -->
|
|
||||||
Links are used everywhere on the web, with the purpose if directing users to various content items. They're usually indicated by your cursor turning into a hand icon. Links can be text, images or other elements contained within your HTML or webpage.
|
|
||||||
|
|
||||||
You use an ```code <a>``` tag or anchor element to define your link, which also also needs a destination address that you'll access with the ```code href``` attribute. Here's a snippet that makes the phrase 'the freeCodeCamp Guide' a link:
|
|
||||||
|
|
||||||
|
You use an anchor element/tag `<a>` to define your link, which also needs a destination address(url) that you'll access with the `href` attribute.
|
||||||
```html
|
```html
|
||||||
<a href="https://guide.freecodecamp.org">the freeCodeCamp Guide</a>
|
<a href="url">Link Text</a>
|
||||||
```
|
```
|
||||||
|
Here's a snippet that makes the phrase 'The freeCodeCamp Guide' a link:
|
||||||
If you'd like your link to open in a new tab, you'll use the ```code target``` attribute along with the ```code "_blank"``` value inside your opening ```code <a>``` tag. That looks like this:
|
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<a href="https://guide.freecodecamp.org" target="_blank">the freeCodeCamp Guide</a>
|
<a href="https://guide.freecodecamp.org">The freeCodeCamp Guide</a>
|
||||||
```
|
```
|
||||||
|
The link ends up looking like this: [The freeCodeCamp Guide](https://guide.freecodecamp.org)
|
||||||
|
|
||||||
When you need to guide users to a specific part of your webpage, let's assume the very bottom, you first need to assign the hash ```code #``` symbol to the ```code href``` attribute, like this
|
### Links in a New Tab
|
||||||
|
If you'd like your link to open in a new tab, you'll use the `target` attribute along with the `"_blank"`
|
||||||
```html
|
value inside your opening `<a>` tag. That looks like this:
|
||||||
<a href="#footer">More about us<a/>
|
```html
|
||||||
|
<a href="url" target="_blank">Link Text</a>
|
||||||
```
|
```
|
||||||
|
Here is another example, using the official freeCodeCamp Guide as the `href=""` destination, and "The freeCodeCamp Guide" as the link text:
|
||||||
you'll then need to use an ```code id``` attribute in the element you want to direct your user to - in this case the ```code <footer>``` at the bottom of the webpage.
|
|
||||||
|
|
||||||
```html
|
```html
|
||||||
|
<!-- target="_blank" makes the link open in a new tab. -->
|
||||||
|
<a href="https://guide.freecodecamp.org" target="_blank">The freeCodeCamp Guide</a>
|
||||||
|
```
|
||||||
|
### Links on the Same Page
|
||||||
|
When you need to guide users to a specific part of your webpage, let's assume the very bottom, you first need to create an html element with an `#id` that you want direct your user to - in this case the `<footer>` at the bottom of the webpage. For example:
|
||||||
|
```html
|
||||||
|
<!-- Here we create a <footer> with an id of #footer -->
|
||||||
<footer id="footer">Powered by freeCodeCamp</footer>
|
<footer id="footer">Powered by freeCodeCamp</footer>
|
||||||
```
|
```
|
||||||
|
Now to link to the footer (make the page scroll down to the footer when you click it), we have to assign the hash `#` symbol to the `href` attribute like this:
|
||||||
|
```html
|
||||||
|
<a href="#footer>More about us<a/>
|
||||||
|
```
|
||||||
|
To demonstrate how this works, here is a link that takes you to the top of this page: <a href="#link-top">Click Here.</a>
|
||||||
|
|
||||||
#### More Information:
|
#### More Information
|
||||||
<!-- Please add any articles you think might be helpful to read before writing the article -->
|
|
||||||
<a href="https://www.w3schools.com/html/html_links.asp" target="_blank">w3sschools - HTML Links</a>
|
* [w3schools - HTML Links](https://www.w3schools.com/html/html_links.asp)
|
||||||
|
* [w3schools - Target Attribute](https://www.w3schools.com/tags/att_a_target.asp)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user