Last active
July 1, 2020 13:23
-
-
Save agustinpfs/8c389d5f3799e02683d1409c5d18e71e to your computer and use it in GitHub Desktop.
Javascript básico. Métodos.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Objeto String. Incluye métodos como: | |
// length Devuelve la longitud de una cadena de texto. | |
var cadena = "hola"; | |
var longitud = cadena.length; | |
console.log(longitud); | |
// toUpperCase() Devuelve la cadena en mayúscula. | |
var cadena = "hola"; | |
var mayuscula = cadena.toUpperCase(); | |
console.log(mayuscula); | |
// Objeto Array. Incluye métodos como: | |
// push() agrega elementos al final del array. | |
let animales = ["gato", "perro", "caballo"] | |
console.log(animales); | |
animales.push("vaca", "conejo") | |
console.log(animales); | |
// length Devuelve la longitud de un arreglo. | |
var animales = ["gato", "perro", "caballo"]; | |
var longitud = animales.length; | |
console.log(longitud); | |
// Objeto Math. Incluye métodos como: | |
// pow() devuelve el resultado de un número(1º argumento) elevado a una potencia(2º argumento). | |
let potencia = Math.pow(5, 2) | |
console.log(potencia); | |
// random() devuelve un número aleatorio entre 0 y 1 | |
console.log(Math.random()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment