getMousePosition
is a simple function that returns an object containing two fields.
ES6 provides the syntactic sugar to eliminate the redundancy of having to write x: x
. You can simply write x
once, and it will be converted tox: x
(or something equivalent) under the hood.
Here is the same function from above rewritten to use this new syntax:
```js
const getMousePosition = (x, y) => ({ x, y });
```
Person
object with name
, age
and gender
properties.
{name: "Zodiac Hasbro", age: 56, gender: "male"}
.'
testString: 'assert((() => {const res={name:"Zodiac Hasbro",age:56,gender:"male"}; const person=createPerson("Zodiac Hasbro", 56, "male"); return Object.keys(person).every(k => person[k] === res[k]);})(), ''The output is {name: "Zodiac Hasbro", age: 56, gender: "male"}
.'');'
- text: No key:value
were used.
testString: getUserInput => assert(!getUserInput('index').match(/:/g), 'No key:value
were used.');
```