Created
April 15, 2018 07:44
-
-
Save nikolayemrikh/a0c702fc3d4f9651130d84a559148ae7 to your computer and use it in GitHub Desktop.
Random data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const audioData = [ | |
| { | |
| artist: `Kevin MacLeod`, | |
| name: `Long Stroll`, | |
| image: `https://yt3.ggpht.com/-fkDeGauT7Co/AAAAAAAAAAI/AAAAAAAAAAA/dkF5ZKkrxRo/s900-c-k-no-mo-rj-c0xffffff/photo.jpg`, | |
| src: `https://www.youtube.com/audiolibrary_download?vid=91624fdc22fc54ed`, | |
| genre: `Jazz` | |
| }, | |
| { | |
| artist: `Jingle Punks`, | |
| name: `In the Land of Rhinoplasty`, | |
| image: `https://i.vimeocdn.com/portrait/992615_300x300`, | |
| src: `https://www.youtube.com/audiolibrary_download?vid=dc3b4dc549becd6b`, | |
| genre: `Rock` | |
| }, | |
| { | |
| artist: `Audionautix`, | |
| name: `Travel Light`, | |
| image: `http://4.bp.blogspot.com/-kft9qu5ET6U/VPFUBi9W-MI/AAAAAAAACYM/UxXilXKYwOc/s1600/audionautix%2BHalf%2BSize.jpg`, | |
| src: `https://www.youtube.com/audiolibrary_download?vid=a127d9b7de8a17cf`, | |
| genre: `Country` | |
| }, | |
| { | |
| artist: `Riot`, | |
| name: `Level Plane`, | |
| image: `https://i.ytimg.com/vi/jzgM3m8Vp1k/maxresdefault.jpg`, | |
| src: `https://www.youtube.com/audiolibrary_download?vid=dfb828f40096184c`, | |
| genre: `R&B` | |
| }, | |
| { | |
| artist: `Jingle Punks`, | |
| name: `Lucky Day`, | |
| image: `https://i.vimeocdn.com/portrait/992615_300x300`, | |
| src: `https://www.youtube.com/audiolibrary_download?vid=bcbe5be936a32fb1`, | |
| genre: `Pop` | |
| }, | |
| { | |
| artist: `Gunnar Olsen`, | |
| name: `Home Stretch`, | |
| image: `https://f4.bcbits.com/img/0004181452_10.jpg`, | |
| src: `https://www.youtube.com/audiolibrary_download?vid=bcbe5be936a32fb1`, | |
| genre: `Electronic` | |
| } | |
| ]; | |
| const getRandomDataSequence = (n, data) => { | |
| const tmpTracks = data.slice(); | |
| const currentTracks = Array.from({length: n}, () => { | |
| const index = Math.floor(Math.random() * tmpTracks.length); | |
| return tmpTracks.splice(index, 1)[0]; | |
| }); | |
| return currentTracks; | |
| }; | |
| const SongsLength = { | |
| ARTIST: 3, | |
| GENRE: 4 | |
| }; | |
| const getWtff = (data) => { | |
| const artistQuestions = []; | |
| const genreQuestions = []; | |
| for (let i = 0, l = data.length; i < l - 1; i++) { | |
| const currData = data[i]; | |
| artistQuestions.push({ | |
| rightAnswer: currData.artist, | |
| songSrc: currData.src, | |
| songs: getRandomDataSequence(SongsLength.ARTIST, data) | |
| }); | |
| genreQuestions.push({ | |
| rightAnswer: currData.name, | |
| genre: currData.genre, | |
| songs:getRandomDataSequence(SongsLength.GENRE, data) | |
| }); | |
| } | |
| return {artistQuestions, genreQuestions}; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment