diff --git a/README.md b/README.md index 4242a29..ce4e322 100644 --- a/README.md +++ b/README.md @@ -6,4 +6,5 @@ If you are a beginner in javascript, or know it, below you can find articles to - ECMAScript [en](content/en/ecma-script.md), [pt-br](content/pt-br/ecma-script.md) - var [en](content/en/var.md), [pt-br](content/pt-br/var.md) -- string [en](content/en/string.md), [pt-br](content/pt-br/string.md) +- String [en](content/en/string.md), [pt-br](content/pt-br/string.md) +- Number [en](content/en/number.md), [pt-br](content/pt-br/number.md) diff --git a/content/en/number.md b/content/en/number.md new file mode 100644 index 0000000..fe4f0c2 --- /dev/null +++ b/content/en/number.md @@ -0,0 +1,58 @@ +## Number + +Another variable type in Javascript is the type Number. + +Is very common in other languages have two or more types to numbers, it is typically a Type integer, and other of type float. sendo normalmente um do tipo inteiro, e outro de tipo flutuante. + +``` +// Examples of integers: +5 +10 +22 +``` + +``` +// and floats +10.5 +0.5 +3.3232 +102.20 +``` + +However in Javascript, integer numbers or floats and floating numbers are actually the same type of variable, Number. We will see later methods to allow us treat these numbers with the precision we desire. + +For now, to create a variable of type Number in Javascript, just assign a value, different of Strings, dont be necessary any special symbol, e.g: + +```js +var averageSizeDragon = 68.5; +var amountDragons = 3; +``` + +We will see more operators in other article, but if you want to advance, below we use some simple operators, to sum, subtract, divide and multiply: + +```js +// soma +10 + 10 +amountDragons + 1 +``` + +Dont forget to test using the `console.log`. + +```js +// subtraction +10 - 5 +amountDragons - 2 +``` + +```js +// multiplication +10 * 10 +amountDragons * averageSizeDragon +``` + +```js +// division +32 / 3 +32 / 2 +amountDragons / averageSizeDragon +``` \ No newline at end of file diff --git a/content/pt-br/number.md b/content/pt-br/number.md new file mode 100644 index 0000000..f585e98 --- /dev/null +++ b/content/pt-br/number.md @@ -0,0 +1,60 @@ +## Number + +Um outro tipo de varíavel existente em Javascript é o tipo Number. + +É comum em outras linguagens termos dois ou mais tipos para números, sendo normalmente um do tipo inteiro, e outro de tipo flutuante. + +```js +// exemplos de números inteiros +5 +10 +22 +``` + + + +```js +// e de tipos flutuantes +10.5 +0.5 +3.3232 +102.20 +``` + +Porém em Javascript, números inteiros ou flutuantes são na verdade um mesmo tipo de variável, Number. Posteriormente veremos métodos que nos permitirá tratar estes números com a precisão que desejarmos. + +Por hora, para criar uma variável do tipo Number em Javascript, simplesmente atribua o valor, diferente de Strings, não é necessário nenhum símbolo especial. Exemplo: + +```js +var averageSizeDragon = 68.5; +var amountDragons = 3; +``` + +Veremos mais operadores em outro artigo, mas se quiser adiantar, abaixo usamos alguns operadores simples, para soma, subtração, divisão e multiplicação: + +```js +// soma +10 + 10 +amountDragons + 1 +``` + +Não se esqueça de testar usando o `console.log`. + +```js +// subtração +10 - 5 +amountDragons - 2 +``` + +```js +// multiplicação +10 * 10 +amountDragons * averageSizeDragon +``` + +```js +// divisão +32 / 3 +32 / 2 +amountDragons / averageSizeDragon +``` \ No newline at end of file