Blog na temat programowania. Wszystkie materia艂y do nauki znajdziesz pod tagiem "materia艂y". Autor - Kamil Naja
Pokazywanie post贸w oznaczonych etykiet膮 exercise. Poka偶 wszystkie posty
Pokazywanie post贸w oznaczonych etykiet膮 exercise. Poka偶 wszystkie posty
艣roda, 28 sierpnia 2019
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.
// 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 :
// 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"]
czwartek, 18 lipca 2019
Programming exercise #8 - dealing with objects
Imagine, that you have array of objects like this:
I want to ask you, about transform this array into one object, that looks like this:
const array = [{ name: "something", value: "something" },{ name: "somethingElse", value: "something else" },{ drinkName: "vodka", value: "Pshenicnaja" }];
I want to ask you, about transform this array into one object, that looks like this:
const res = { name: 'somethingElse', value: 'Pshenicnaja', drinkName: 'vodka' }
As you can see, we do not want get duplicated keys in result.
poniedzia艂ek, 15 lipca 2019
Programming exercise #7 - promises basics
Very simple exercise - please create a promise, that returns some text after 2 seconds. When there was an error, console.error message.
Also do the same, using async and await syntax.
Also do the same, using async and await syntax.
niedziela, 30 czerwca 2019
Programming exercise #6 - start emitting value, when all items emits something [rxjs]
So, new RXJS exercise:
Create two buttons like this:
const button1 = document.querySelector('#btn1');
const button2 = document.querySelector('#btn2');
After click on every button emit some value, but start doing this only, when user click both first and second button. When this rule is satisfied, emit last value.
Create two buttons like this:
const button1 = document.querySelector('#btn1');
const button2 = document.querySelector('#btn2');
After click on every button emit some value, but start doing this only, when user click both first and second button. When this rule is satisfied, emit last value.
Programming exercise #5 - Merge multiple observables (RXJS)
Today programming exercise:
You have two buttons on website like this:
<button id="btn1">Button1</button>
<button id="btn2">Button2</button>
Subscribe to click event on those two buttons and on every click, emit text "button 1" or "button 2". Use merge method, to create one observable from two.
You can also create two intervals, that emits some value, and merge them into one observable.
You have two buttons on website like this:
<button id="btn1">Button1</button>
<button id="btn2">Button2</button>
Subscribe to click event on those two buttons and on every click, emit text "button 1" or "button 2". Use merge method, to create one observable from two.
You can also create two intervals, that emits some value, and merge them into one observable.
艣roda, 1 maja 2019
Programming Exercise #4 - Observable from promise (RxJs)
Quick exercise Goal - Create an observable from Promise. After two seconds from start, this should log 'hello' message. I suggest you to use setTimeout() method.
sobota, 16 marca 2019
Programming exercise #3 - display elements from array with delay
In this exercise, I strong recommend using rxjs.
Input
Array of values (number of strings)
const arr = [1, 2, 3, 4, 5, 6];
Expected result
Display values from array with delay. For example output 1 => one second later output 2 => one second later output 3 etc
pi膮tek, 22 lutego 2019
Programming exercise #2 - double every property in object in array.
Hi, today exercise:
You got an array of objects, for example:
let objArr = [{id: 1, name: 'Kamil'},
{id: 2, name: 'Janusz'}, {id: 3, name: 'Mariusz'}];
Create an function, that takes this array and returns the same data, every id should be doubled.
You can also just display data in console.log or print fn.
let res = [{name: "Kamil", id: 2},
{name: "Janusz", id: 4},{name: "Mariusz", id: 6}]
Feel free to send your implementation in comments section!
czwartek, 21 lutego 2019
Programming exercise #1 - find every second and add new line
Recently, I found interesting topic on SO, about parsing string in JS.
The exercise is:
Create function, that takes a string and returns string. Every second word should have added new line character "\n".
For example
The exercise is:
Create function, that takes a string and returns string. Every second word should have added new line character "\n".
For example
let stringToParse = `How good is have account on and create new posts` let result = "How good is have account on StackOverflow and create new postsPlease place your answer (in any language) in comments section.
Subskrybuj:
Posty (Atom)