Skip to content

Instantly share code, notes, and snippets.

@QuocCao-dev
Created September 24, 2022 09:34
Show Gist options
  • Save QuocCao-dev/bebbb2d83ab57effb69c6f0cff84621b to your computer and use it in GitHub Desktop.
Save QuocCao-dev/bebbb2d83ab57effb69c6f0cff84621b to your computer and use it in GitHub Desktop.
var name = "Francis";
var lastname = "Jones"
var age = 23;
var obj
function createObject(name,lastname,age){
obj = {
name:name,
lastname:lastname,
age:age,
}
return obj;
}
console.log(createObject(name,lastname,age))
@NhanKhangg98
Copy link

NhanKhangg98 commented Sep 24, 2022

let name = "Francis"
let lastName = "Jones"
let age = 23
const createObject = ({name, lastName, age}) => {
let obj = {
name,
lastName,
age
}
return obj;
}
console.log(createObject({name, lastName, age}))

@buymed-hoangpham
Copy link

buymed-hoangpham commented Sep 24, 2022

const name = 'Francis',
	lastname = 'Jones',
	age = 23;
let obj;

function createObject(name, lastname, age) {
	return (obj = {
		name,
		lastname,
		age,
	});
}
console.log(createObject(name, lastname, age));

@QuocCao-dev
Copy link
Author

QuocCao-dev commented Sep 24, 2022

const name = "Francis";
const lastname = "Jones";
const age = 23;

function createObject({ name, lastname, age }) {
  return {
    name,
    lastname,
    age,
  };
}

const person = { name, lastname, age };

createObject(person);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment