środa, 28 sierpnia 2019

Programming exercise #13 - get only unique items from array of objects

// so, you have list of users like this
const users = [
{ id: '1', name: 'hello' },
{ id: '2', name: 'world' },
{ id: '3', name: 'hello' },
{ id: '1', name: 'hello' },
{ id: '1', name: 'hello' },
]
// as a result, we want to get list of users without duplicates, basing on id.
const res = [
{ id: '1', name: 'hello' },
{ id: '2', name: 'world' },
{ id: '3', name: 'hello' }
]
// I suggest you, not to use forEach or for methods.
view raw gistfile1.txt hosted with ❤ by GitHub

sobota, 17 sierpnia 2019

Programming exercise #12 Count, how many certain items exists in array of objects.

// So, you have input data like this
let objArr = [
{ id: 1, name: 'Kamil' },
{ id: 2, name: 'Janusz' },
{ id: 3, name: 'Mariusz' },
{ id: 4, name: 'Alina' },
{ id: 5, name: 'Olo' } ];
// Please count, how many names in your array contains letter 'm'.
// I suggest you, to use RXJS.
view raw count.ts hosted with ❤ by GitHub

czwartek, 15 sierpnia 2019

Programming exercise #11 - Clone object, without copying reference

// So, you have object like this

const obj = {
firstName: "John",
lastName: "Doe"
}

//Please create second object, that have firstName and lastName
// properties from first object.

console.log(myClonedObject) // {firstName: "John", lastName: "Doe"}

// Your goal is copy only properties, not the reference to object.
// so when we change first object like this :

obj.firstName = "Mary"

// output on cloned object should look the same.

console.log(myClonedObject) // {firstName: "John", lastName: "Doe"}

// Please post your answer as codepen, jsbin or link into your github gist.

piątek, 9 sierpnia 2019

Programming exercise #10 - emit 6 values in interval, remember about reseting

// Interesting exercise, that I have found in StackOverflow

// After click in button, return values from 0 to 6 with interval 1000 ms.
// After every click in button, again start emitting from 0 to 6
// I suggest you, to use rxjs

Programming exercise #9 - one array from two

// Simple exercise for today
// Your goal is to merge two arrays into one.

const arr1 = ["a", "b", "c"];
const arr2 = ["e", "f", "g"];

// expected result ["a", "b", "c", "e", "f", "g"]