Skip to content

Instantly share code, notes, and snippets.

View rxluz's full-sized avatar

Ricardo Luz rxluz

View GitHub Profile
function showNameAndAge({name = 'Ricardo', age = 32}){
return `Hello ${name}, you are ${age} years old`;
}
showNameAndAge({name: 'Ricardo', age: 32}); //right
showNameAndAge({age: 32, name: 'Ricardo'}); //also right!
showNameAndAge(); //also right!
const profile = {
name: 'Ricardo',
age: 32,
eyes: 'Brown',
orign: 'Brazil',
occupation: 'Fullstack dev'
};
const { name, age } = profile;
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1.0, user-scalable=0, shrink-to-fit=no">
<meta name="HandheldFriendly" content="true">
<title>Your application title</title>
<style>
<h3>Welcome to the real-time HTML editor!</h3>
<p>Type HTML in the textarea above, and it will magically appear in the frame below.</p>
<iframe id="dddjhj" src="https://htmledit.squarefree.com/conteudo1" style="width: 100%" /></iframe>
<button onclick="document.getElementById('dddjhj').src = 'https://htmledit.squarefree.com/conteudo2'"> mudar </button>
<script>
<script>
function changeContent(idx){
var content = [
{text: "flavio", img: "https://i.pinimg.com/originals/81/6d/a5/816da533638aee63cfbd315ea24cccbd.jpg" },
{text: "ricardo", img: "https://ih1.redbubble.net/image.369380617.6838/flat,800x800,075,f.u4.jpg" },
{text: "antonio", img: "https://static.boredpanda.com/blog/wp-content/uploads/2017/03/Evil-Cats-Demons-Summoning-Satan-125-58d223c94bf80__605.jpg" },
]
document.getElementById('btn'+idx).innerHTML = content[idx].text;
@rxluz
rxluz / getAge.js
Last active January 20, 2019 06:41
9 Big O in JS: The basic that you need to know, see more at: https://medium.com/front-end-weekly/big-o-in-js-the-basic-that-you-need-to-know-a5abb45570fa
const people = {
aline: 26,
john: 35,
peter: 21,
james: 45
};
const getAge = name => people[name];
@rxluz
rxluz / greaterThan18.js
Last active January 20, 2019 06:49
Big O in JS: The basic that you need to know, see more at: https://medium.com/p/a5abb45570fa
const people = [
{ name: 'lucy', age: 13},
{ name: 'aline', age: 13},
{ name: 'john', age: 35},
{ name: 'peter', age: 21},
{ name: 'james', age: 45},
{ name: 'marcela', age: 17},
];
const getGreaterThan18 = () => people.filter(person => person.age > 18);
@rxluz
rxluz / printItemAndNextO2.js
Last active January 20, 2019 06:50
Big O in JS: The basic that you need to know, see more at: https://medium.com/p/a5abb45570fa
const printItemAndNext = (...items) =>
items.forEach((item, index) =>
items.forEach(
(innerItem, innerIndex) =>
innerIndex === index + 1 && console.log(item, innerItem),
),
);
/* will return:
1 2
@rxluz
rxluz / printItemAndNextO1.js
Last active January 20, 2019 06:50
Big O in JS: The basic that you need to know, see more at: https://medium.com/p/a5abb45570fa
const printItemAndNextItem = (...items) =>
items.forEach(
(item, index) => items[index + 1] && console.log(item, items[index + 1]),
);
/* will return:
1 2
2 3
3 4
*/
@rxluz
rxluz / peopleData.js
Last active January 20, 2019 06:50
Big O in JS: The basic that you need to know, see more at: https://medium.com/p/a5abb45570fa
const people = [
{
name: "Joseph",
age: 32,
gender: "male",
},
{
name: "Anna",
age: 27,
gender: "female",