var name = "Mauricio"
var age = 30
var isDeveloper = true
var birthDate = new Date(1990, 7, 17)
var list = [name, age, isDeveloper, birthDate]
console.log(list)
function fecha(dia, mes, anio){
return [dia, mes, anio]
}
fecha(21, 7, 2000)
function getUserInfo(){
return [
"Josue",
25,
true,
new Date("1992-02-08")
];
}
var nombres = ["juan", "juan", "juan", "juan", "juan", "juan", "pedro", "pedro", "pedro", "pedro", "pedro", "pedro", "maria", "maria", "maria", "maria", "maria", "maria", "jose", "jose", "jose", "jose", "jose", "jose", "miguel", "miguel", "miguel", "miguel", "miguel", "miguel", "javier", "javier", "javier", "javier", "javier", "javier", "jorge", "jorge", "jorge", "jorge", "jorge", "jorge", "jorge", "jorge", "jorge", "jorge", "jorge", "jorge", "jorge", "jorge", "jorge", "jorge", "jorge", "jorge", "jorge", "jorge", "jorge", "jorge", "jorge", "j
function next_pal(){
var num = prompt("Escribe un número:");
var next_num = parseInt(num) + 1;
console.log(next_num);
}
function stars(namesArray) {
result = []
for (let i = 0; i < namesArray.length; i++) {
name = namesArray[i]
stars = ""
for (let j = 0; j < namesArray.filter(n => n == name).length; j++) {
stars += "*"
}
result.push(name + " " + stars)
}
return result
}
stars(["Ana", "Juan", "Juan", "Ana"])
let info = [
'Alberto',
25,
true,
new Date('1995-01-01')
]
const items = [
'Diego',
25,
true,
Date.now()
]
function createPhoneNumber(numbers){
return "(" + numbers[0] + numbers[1] + numbers[2] + ") " + numbers[3] + numbers[4] + numbers[5] + "-" + numbers[6] + numbers[7] + numbers[8] + numbers[9];
}
// Example:
// createPhoneNumber([1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) // => returns "(123) 456-7890"
function createPhoneNumber(numbers){
var format = "(xxx) xxx-xxxx";
for(var i = 0; i < numbers.length; i++)
{
format = format.replace('x', numbers[i]);
}
return format;
};
console.log(createPhoneNumber([2, 3, 4, 5, 1, 2, 1, 2, 2, 1]))
function countNameRepetitions(names) {
//write your code here
return names.reduce((acum, curr) => {
if(!acum.hasOwnProperty(curr)){
acum[curr] = 1
} else {
acum[curr]++
}
return acum
}, {})
}
countNameRepetitions([
'Ana',
'Ana',
'Ana',
'Juan',
'Juan',
'Pedro',
'Pedro',
'Maria',
'Maria'
])
function myInfo(firstName, age, isDev, birthDate){
return [firstName, age, isDev, birthDate]
}
myInfo('Raul', 28, true, new Date(1988, 8, 28))
function countNameRepetitions(names) {
/*
names = ['Rafael', 'Juan', 'Alberto', 'Rafael'];
output = {
Rafael: 2,
Juan: 1,
Alberto: 1
}
*/
var table = {};
for (var i = 0; i < names.length; i++) {
var name = names[i];
if (table[name] === undefined) {
table[name] = 0;
}
table[name] += 1;
}
return table;
}
function next_pal(n) {
var palindrome = n;
while (true) {
palindrome++;
if (palindrome == parseInt(palindrome.toString().split('').reverse().join(''))) {
return palindrome;
}
}
}
function next_pal(n) {
var isPalindrome = false;
var length = String(n).length;
if (length === 1) {
length = 2;
}
while (isPalindrome === false) {
n = n + 1;
var array = String(n).split("");
var half = array.length / 2;
var half1 = array.slice(0, half).join("");
var half2 = array.slice(half, length).join("");
var reverse = half2.split("").reverse().join("");
if (half1 === reverse) {
isPalindrome = true;
} else {
isPalindrome = false;
}
}
return n;
}
function createList(name, age, developer, bornDate){
return [name, age, developer, bornDate];
}
var d = new Date();
var strDate = d.getFullYear() + "/" + (d.getMonth()+1) + "/" + d.getDate();
var list = ['Thomas', 20, true, strDate];
function next_pal(n) {
while (true) {
n++;
if (n.toString() == n.toString().split('').reverse().join('')) {
return n;
}
}
}
next_pal(9);
function getList(){
return ["Rojo",23,true,"04/06/1995"]
}