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
let stringToParse = `How good is have account on and create new posts`
let result = "How good
is have
account on
StackOverflow and
create new
posts

Please place your answer (in any language) in comments section.