From be27c064b14e2f108520778ac545383d693fdec3 Mon Sep 17 00:00:00 2001 From: oridavidi100 Date: Wed, 8 Sep 2021 11:33:51 +0300 Subject: [PATCH 01/39] function playsong running on the songs array --- index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 10f4784..836cd91 100644 --- a/index.js +++ b/index.js @@ -53,7 +53,11 @@ const player = { } function playSong(id) { - // your code here + for (let i=0;i Date: Wed, 8 Sep 2021 11:37:21 +0300 Subject: [PATCH 02/39] Update index.js checking and return the correct id --- index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 836cd91..d207d8b 100644 --- a/index.js +++ b/index.js @@ -54,10 +54,10 @@ const player = { function playSong(id) { for (let i=0;i Date: Wed, 8 Sep 2021 11:50:01 +0300 Subject: [PATCH 03/39] playsong adding throw and fix the if --- index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index d207d8b..e83a819 100644 --- a/index.js +++ b/index.js @@ -54,10 +54,11 @@ const player = { function playSong(id) { for (let i=0;i Date: Wed, 8 Sep 2021 11:57:53 +0300 Subject: [PATCH 04/39] Update index.js running on the songs array --- index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index e83a819..0edde4e 100644 --- a/index.js +++ b/index.js @@ -58,11 +58,13 @@ function playSong(id) { return player.songs[i] } } - throw ("no such id ,try another one") + throw ("non-existent ID,try another one") } function removeSong(id) { - // your code here + for (let i=0;i Date: Wed, 8 Sep 2021 12:10:10 +0300 Subject: [PATCH 05/39] function add song adding song the the array songs by push function --- index.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 0edde4e..046ad5e 100644 --- a/index.js +++ b/index.js @@ -64,11 +64,18 @@ function playSong(id) { function removeSong(id) { for (let i=0;i Date: Wed, 8 Sep 2021 12:23:44 +0300 Subject: [PATCH 06/39] Update index.js remove from playlists --- index.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 046ad5e..549f02e 100644 --- a/index.js +++ b/index.js @@ -67,9 +67,15 @@ function removeSong(id) { player.songs.splice(i,1) } } + for (let i=0;i Date: Wed, 8 Sep 2021 12:37:00 +0300 Subject: [PATCH 07/39] remove song if the id isnt existent the function throw non existent --- index.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/index.js b/index.js index 549f02e..69d47f9 100644 --- a/index.js +++ b/index.js @@ -62,6 +62,11 @@ function playSong(id) { } function removeSong(id) { + let a=0; + for(let x=0;x Date: Wed, 8 Sep 2021 12:49:04 +0300 Subject: [PATCH 08/39] add song function checking if the id has already taken --- index.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/index.js b/index.js index 69d47f9..74ec0b9 100644 --- a/index.js +++ b/index.js @@ -81,12 +81,19 @@ function removeSong(id) { } function addSong(title, album, artist, duration, id=12) { + let a=0; + for(let x=0;x Date: Wed, 8 Sep 2021 12:58:53 +0300 Subject: [PATCH 09/39] add song function duration format --- index.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/index.js b/index.js index 74ec0b9..fb85629 100644 --- a/index.js +++ b/index.js @@ -86,6 +86,12 @@ function addSong(title, album, artist, duration, id=12) { if (player.songs[x].id===id) a=1} if (a===1) throw ("existent ID,try another one"); + let b=0; + for (let i=0;i Date: Wed, 8 Sep 2021 13:19:10 +0300 Subject: [PATCH 10/39] add song changing the input duration to mm:ss --- index.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/index.js b/index.js index fb85629..9a962c4 100644 --- a/index.js +++ b/index.js @@ -48,14 +48,14 @@ const player = { { id: 5, name: 'Israeli', songs: [4, 5] }, ], playSong(song) { - console.log(/* your code here */) + console.log(playsong(id)) }, } function playSong(id) { for (let i=0;i Date: Wed, 8 Sep 2021 13:42:02 +0300 Subject: [PATCH 11/39] remove playlists function runing on the playlists by for loop checking which playlist has this id and remove her --- index.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 9a962c4..c3300f6 100644 --- a/index.js +++ b/index.js @@ -92,16 +92,24 @@ function addSong(title, album, artist, duration, id=12) { duration= (minutes +":"+seconds) player.songs.push({"id":id, "title":title, - "album":album, - "artist":artist, - "duration":duration + "album":album, + "artist":artist, + "duration":duration }) return player.songs[player.songs.length-1].id } function removePlaylist(id) { - // your code here + let a=0; + for (let i=0;i Date: Wed, 8 Sep 2021 13:44:55 +0300 Subject: [PATCH 12/39] create playlist function optional id --- index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/index.js b/index.js index c3300f6..8c40471 100644 --- a/index.js +++ b/index.js @@ -112,8 +112,7 @@ function removePlaylist(id) { } -function createPlaylist(name, id) { - // your code here +function createPlaylist(name, id=6) { } function playPlaylist(id) { From 28612a5e9229351bfc23acf8650e642f3feee1b7 Mon Sep 17 00:00:00 2001 From: oridavidi100 Date: Wed, 8 Sep 2021 13:50:00 +0300 Subject: [PATCH 13/39] createPlaylist function checking if the id is already taken --- index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/index.js b/index.js index 8c40471..396f67a 100644 --- a/index.js +++ b/index.js @@ -113,6 +113,10 @@ function removePlaylist(id) { } function createPlaylist(name, id=6) { + let a=0; + for(let x=0;x Date: Wed, 8 Sep 2021 13:50:57 +0300 Subject: [PATCH 14/39] createPlaylist insert to laylists the new playlist --- index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/index.js b/index.js index 396f67a..2a71256 100644 --- a/index.js +++ b/index.js @@ -117,6 +117,10 @@ function createPlaylist(name, id=6) { for(let x=0;x Date: Wed, 8 Sep 2021 13:59:48 +0300 Subject: [PATCH 15/39] create playlists function reutrn the id of the new playlist --- index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 2a71256..14c0cce 100644 --- a/index.js +++ b/index.js @@ -112,15 +112,17 @@ function removePlaylist(id) { } -function createPlaylist(name, id=6) { +function createPlaylist(name, id=10) { let a=0; for(let x=0;x Date: Wed, 8 Sep 2021 14:13:44 +0300 Subject: [PATCH 16/39] playplaylists function run for the id numbers in songs in playlists then its searching for the song with this id in songs end print him by the order --- index.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 14c0cce..4a6c026 100644 --- a/index.js +++ b/index.js @@ -126,7 +126,21 @@ function createPlaylist(name, id=10) { } function playPlaylist(id) { - // your code here + let a=0; + for (let i=0;i Date: Wed, 8 Sep 2021 14:26:42 +0300 Subject: [PATCH 17/39] edit playlists find the playlist --- index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 4a6c026..8fc6a71 100644 --- a/index.js +++ b/index.js @@ -144,7 +144,12 @@ function playPlaylist(id) { } function editPlaylist(playlistId, songId) { - // your code here + let list; + for (let x=0;x Date: Wed, 8 Sep 2021 14:39:53 +0300 Subject: [PATCH 18/39] edit playlists function checking if the song id is in and alone in the array and delete the playlist --- index.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 8fc6a71..27b23ea 100644 --- a/index.js +++ b/index.js @@ -144,11 +144,16 @@ function playPlaylist(id) { } function editPlaylist(playlistId, songId) { + let y; let list; for (let x=0;x Date: Wed, 8 Sep 2021 14:44:47 +0300 Subject: [PATCH 19/39] edit playlists function check if the sonId is in the array and not alone and delete the songId --- index.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/index.js b/index.js index 27b23ea..92bf3fa 100644 --- a/index.js +++ b/index.js @@ -154,9 +154,12 @@ function editPlaylist(playlistId, songId) { for (let i=0;i1) + list.songs.splice(i,1) } } + function playlistDuration(id) { // your code here } From 14d480f492ef3b2ae44fabd4b3775d5f6a9d42d5 Mon Sep 17 00:00:00 2001 From: oridavidi100 Date: Wed, 8 Sep 2021 14:50:17 +0300 Subject: [PATCH 20/39] edit playlist function if songId isnt in the array then add him to the array --- index.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 92bf3fa..7cd60ac 100644 --- a/index.js +++ b/index.js @@ -144,6 +144,7 @@ function playPlaylist(id) { } function editPlaylist(playlistId, songId) { + let a; let y; let list; for (let x=0;x1) - list.songs.splice(i,1) + if (list.songs[i]===songId&&list.songs.length<2){ + a=1; + player.playlists.splice(y,1)} + else if (list.songs[i]===songId&&list.songs.length>1){ + a=1; + list.songs.splice(i,1)} } + if (a===0){ list.songs.push(songId) } } From ebb8ba2d44370404ad02374ecc8fdb51bf5a6c02 Mon Sep 17 00:00:00 2001 From: oridavidi100 Date: Wed, 8 Sep 2021 14:57:10 +0300 Subject: [PATCH 21/39] edit playlists check if the song id is exist --- index.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/index.js b/index.js index 7cd60ac..04bef55 100644 --- a/index.js +++ b/index.js @@ -144,6 +144,13 @@ function playPlaylist(id) { } function editPlaylist(playlistId, songId) { + let z=0; + for (let j=0;j Date: Wed, 8 Sep 2021 15:17:49 +0300 Subject: [PATCH 22/39] playlist duration function finds the playlist --- index.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 04bef55..7ac5107 100644 --- a/index.js +++ b/index.js @@ -151,7 +151,7 @@ function editPlaylist(playlistId, songId) { } } if (z===0)throw ("non existing songId please try another") - let a; + let a=0; let y; let list; for (let x=0;x Date: Wed, 8 Sep 2021 15:32:28 +0300 Subject: [PATCH 23/39] playlist duration function checking the duration of each song id and calculate the sum of them together --- index.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 7ac5107..c39d0b9 100644 --- a/index.js +++ b/index.js @@ -172,12 +172,22 @@ function editPlaylist(playlistId, songId) { function playlistDuration(id) { + let sum=0; let list; for (let x=0;x Date: Wed, 8 Sep 2021 15:37:50 +0300 Subject: [PATCH 24/39] playlistDuration function add try and catch in case that input non existent playlist id --- index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index c39d0b9..77827c2 100644 --- a/index.js +++ b/index.js @@ -174,7 +174,7 @@ function editPlaylist(playlistId, songId) { function playlistDuration(id) { let sum=0; let list; - for (let x=0;x Date: Wed, 8 Sep 2021 16:05:30 +0300 Subject: [PATCH 25/39] serach by query function runs on the player song --- index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 77827c2..9f48f82 100644 --- a/index.js +++ b/index.js @@ -193,7 +193,8 @@ catch{ throw ("non-existent playlist Id please try another")} } function searchByQuery(query) { - // your code here + let arrSongs=[]; + for (let x=0;x Date: Wed, 8 Sep 2021 16:06:29 +0300 Subject: [PATCH 26/39] search by query cheking if the query fits --- index.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/index.js b/index.js index 9f48f82..32ec119 100644 --- a/index.js +++ b/index.js @@ -195,6 +195,9 @@ catch{ throw ("non-existent playlist Id please try another")} function searchByQuery(query) { let arrSongs=[]; for (let x=0;x Date: Wed, 8 Sep 2021 16:07:40 +0300 Subject: [PATCH 27/39] search by query function pushing to an array the wanted title songs --- index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 32ec119..88f50f7 100644 --- a/index.js +++ b/index.js @@ -196,8 +196,9 @@ function searchByQuery(query) { let arrSongs=[]; for (let x=0;x Date: Wed, 8 Sep 2021 16:19:45 +0300 Subject: [PATCH 28/39] search by query function runs on the playlists and checke them by the query then push to arrplaylists the wanted playlist names --- index.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/index.js b/index.js index 88f50f7..e65c3a2 100644 --- a/index.js +++ b/index.js @@ -193,12 +193,20 @@ catch{ throw ("non-existent playlist Id please try another")} } function searchByQuery(query) { + let arrPlaylist=[]; let arrSongs=[]; for (let x=0;x Date: Wed, 8 Sep 2021 16:20:26 +0300 Subject: [PATCH 29/39] search by query function returns the arrays --- index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/index.js b/index.js index e65c3a2..6dad368 100644 --- a/index.js +++ b/index.js @@ -207,6 +207,7 @@ function searchByQuery(query) { arrPlaylist.push(player.playlists[i].name) } } + return ("songs \b"+arrSongs+"\n playlists \b"+arrPlaylist) } function searchByDuration(duration) { From 86edf4ab74341ce3ac1e405a34ec180f7a638d03 Mon Sep 17 00:00:00 2001 From: oridavidi100 Date: Wed, 8 Sep 2021 21:58:04 +0300 Subject: [PATCH 30/39] fixing problems o insted of 0 and id optiional by finding max id and giving a new id --- index.js | 57 +++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 21 deletions(-) diff --git a/index.js b/index.js index 6dad368..c25c70f 100644 --- a/index.js +++ b/index.js @@ -47,10 +47,11 @@ const player = { { id: 1, name: 'Metal', songs: [1, 7, 4] }, { id: 5, name: 'Israeli', songs: [4, 5] }, ], - playSong(song) { - console.log(playsong(id)) - }, -} + playSong(song){ + console.log(`Playing ${song.title} from ${song.album} by ${song.artist} | ${convertDuration1(song.duration)}.`); + } + } + function playSong(id) { for (let i=0;i max) + max = arr[i].id; + } + return max; +} + +function addSong(title, album, artist, duration, id) { + if (id===undefined) + id=maxID(player.songs)+1; + let time=0; let a=0; - for(let x=0;x Date: Thu, 9 Sep 2021 11:40:21 +0300 Subject: [PATCH 31/39] search by duration function close function that funds the closet number in array to tour number --- index.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index c25c70f..c2815c5 100644 --- a/index.js +++ b/index.js @@ -48,7 +48,7 @@ const player = { { id: 5, name: 'Israeli', songs: [4, 5] }, ], playSong(song){ - console.log(`Playing ${song.title} from ${song.album} by ${song.artist} | ${convertDuration1(song.duration)}.`); + console.log(`"Playing ${song.title} from ${song.album} by ${song.artist} | ${convertDuration1(song.duration)}."`); } } @@ -207,24 +207,31 @@ catch{ throw ("non-existent playlist Id please try another")} } function searchByQuery(query) { - query.toLowerCase() + query=query.toLowerCase() let results={Playlists:[], Songs:[]} for (let x=0;x Date: Thu, 9 Sep 2021 11:41:07 +0300 Subject: [PATCH 32/39] search by duration changing mm:ss to number --- index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index c2815c5..020556c 100644 --- a/index.js +++ b/index.js @@ -233,7 +233,11 @@ function close(goal,counts){ } function searchByDuration(duration) { - // your code here + function searchByDuration(duration) { + let arr=duration.split(":") + var c = parseInt(arr[0]) + var b = parseInt(arr[1]) + duration =(c*60 + b) } module.exports = { From b8fe3d07dc4fdb8d05b4158de252747a773bfb10 Mon Sep 17 00:00:00 2001 From: oridavidi100 Date: Thu, 9 Sep 2021 11:41:51 +0300 Subject: [PATCH 33/39] search by duration pushing all our duration to array --- index.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/index.js b/index.js index 020556c..5074eac 100644 --- a/index.js +++ b/index.js @@ -238,6 +238,13 @@ function searchByDuration(duration) { var c = parseInt(arr[0]) var b = parseInt(arr[1]) duration =(c*60 + b) + let durArr=[]; + let min; + for (let i=0;i Date: Thu, 9 Sep 2021 11:42:27 +0300 Subject: [PATCH 34/39] search by duration function finding the closet number --- index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/index.js b/index.js index 5074eac..e258feb 100644 --- a/index.js +++ b/index.js @@ -245,6 +245,7 @@ function searchByDuration(duration) { } for (let x=0;x Date: Thu, 9 Sep 2021 11:43:03 +0300 Subject: [PATCH 35/39] search by duration finds the fits song our playlist --- index.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/index.js b/index.js index e258feb..3f65c89 100644 --- a/index.js +++ b/index.js @@ -246,6 +246,17 @@ function searchByDuration(duration) { for (let x=0;x Date: Sat, 11 Sep 2021 12:57:05 +0300 Subject: [PATCH 36/39] search by query sort by abc the array of playlts --- index.js | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/index.js b/index.js index 3f65c89..ad611f3 100644 --- a/index.js +++ b/index.js @@ -210,18 +210,23 @@ function searchByQuery(query) { query=query.toLowerCase() let results={Playlists:[], Songs:[]} - for (let x=0;x b.name) { return 1; } + return 0; +}) return results; } function close(goal,counts){ @@ -233,32 +238,29 @@ function close(goal,counts){ } function searchByDuration(duration) { - function searchByDuration(duration) { - let arr=duration.split(":") - var c = parseInt(arr[0]) - var b = parseInt(arr[1]) - duration =(c*60 + b) - let durArr=[]; - let min; - for (let i=0;i Date: Sat, 11 Sep 2021 21:57:08 +0300 Subject: [PATCH 37/39] Update index.js --- index.js | 48 +++++++++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/index.js b/index.js index ad611f3..f437ba2 100644 --- a/index.js +++ b/index.js @@ -47,9 +47,9 @@ const player = { { id: 1, name: 'Metal', songs: [1, 7, 4] }, { id: 5, name: 'Israeli', songs: [4, 5] }, ], - playSong(song){ - console.log(`"Playing ${song.title} from ${song.album} by ${song.artist} | ${convertDuration1(song.duration)}."`); - } + playSong(song) { + console.log(`Playing ${song.title} from ${song.album} by ${song.artist} | ${durationConvert(song.duration)}.`) + }, } @@ -207,28 +207,38 @@ catch{ throw ("non-existent playlist Id please try another")} } function searchByQuery(query) { - query=query.toLowerCase() - let results={Playlists:[], - Songs:[]} - for (let x=0 ; x b.name) { return 1; } + obj.songs.sort(function (a, b) { + if (a.title < b.title){ + return -1; } + else if (a.title > b.title){ + return 1; } return 0; -}) - return results; + }) + return obj; } + function close(goal,counts){ var closest = counts.reduce(function(prev, curr) { return (Math.abs(curr - goal) < Math.abs(prev - goal) ? curr : prev); From ab2a25254ea6938c12889591e70ae4c09a40ff1f Mon Sep 17 00:00:00 2001 From: oridavidi100 Date: Sat, 11 Sep 2021 21:59:17 +0300 Subject: [PATCH 38/39] Update README.md readme --- README.md | 96 +++---------------------------------------------------- 1 file changed, 5 insertions(+), 91 deletions(-) diff --git a/README.md b/README.md index 290ef50..3e7d587 100644 --- a/README.md +++ b/README.md @@ -1,91 +1,5 @@ -# MP3 Player - Second Weekend Assignment -You are going to implement an MP3 player. - - -## Instructions -1. Fork this repo into your account. -2. Clone the forked repo to your computer. -3. Execute `npm install` in the project folder to install the [tests](#testing). -4. Create a new git branch for your work. -5. Complete the project [requirements](#requirements). -6. Remember to push your commits regularly to GitHub. -7. Submit your work (explanation [below](#submission)) -8. Good luck & have fun! - - -## Requirements -The player itself is an object that has: -- `songs`: an array of songs -- `playlists`: an array of playlists -- `playSong`: a method that plays a song. -It receives a song object and should print the following format `"Playing {song.title} from {song.album} by {song.artist} | {song.duration}."` (replace the stuff inside the `{}` with the real values). -The song duration should be in `mm:ss` format (for example 02:40). - -A song object has: -- `id`: a unique ID (a number) -- `title`: a title -- `album`: album title -- `artist`: artist name -- `duration`: duration (number, in seconds) - -A playlist object has: -- `id`: a unique ID (a number) -- `name`: a name -- `songs`: an array of song IDs - -You are asked to implement the following functions: -- `playSong` - Gets a song ID. Uses `player.playSong` to play the song with the given ID. -- `removeSong` - Gets a song ID. Removes the song with the given ID from the player (from songs and playlists). -- `addSong` - Gets a title, album, artist, duration & ID. Adds a new song with given properties to the player. The ID is optional, and if omitted should be automatically generated. The song duration should be in `mm:ss` format (for example 06:27). Returns the ID of the new song. -- `removePlaylist` - Gets a playlist ID. Remove the playlist with the given ID from the player (does not delete the songs inside it). -- `createPlaylist` - Gets a name & ID. Creates a new, empty playlist with the given details. The ID is optional, and if omitted should be automatically generated. Returns the ID of the new playlist. -- `playPlaylist` - Gets a playlist ID. Plays all songs in the specified playlist, in the order the appear in the playlist. -- `editPlaylist` - Gets a playlist ID & a song ID. If the song ID exists in the playlist, removes it. If it was the only song in the playlist, also deletes the playlist. If the song ID does not exist in the playlist, adds it to the end of the playlist. -- `playlistDuration` - Gets a playlist ID. Returns the total duration of the entire playlist with the given ID. -- `searchByQuery` - Gets a query string. Returns a results object, which has: - - `songs`: an array of songs in which either title or album or artist contain the query string. The songs should be sorted by their titles. - - `playlists`: an array of playlists in which the name contains the query string. The playlists should be sorted by their names. - - The comparison in both cases should be case-insensitive. -- `searchByDuration` - Gets a duration in `mm:ss` format (for example 11:03). Returns the song, or playlist, with the closest duration to what was given. - - -## Testing -We have added some automated tests for you to use. They will help you make sure your code covers the requirements. - -To run the tests, execute `npm run test` in the project folder. - -__Note__: These tests might not cover everything. Don't just count on them. You should remain responsible and vigilant for other possible edge-cases. - - -## Grading -Your work will be graded based on the following considerations: -- The number of automatic tests you pass -- Readable and ordered code - - Spacing & indentation - - Indicative vairable/function names - - Comments (where necessary) -- Proper use of Git - - Granular commits - - Descriptive commit messages -- Extra features you might have added - - -## Submission -1. On GitHub, open a pull request from your branch to the main branch. -2. __Do not merge the pull request!__ -3. Add the user `Cyber4sPopo` as collaborator to your repo. -4. Submit a link to the pull request in Google Classroom. - - -## Important Tip -Try to work in small iterations. You've got a big and complex task ahead of you. Break it down into smaller tasks. Concentrate on making small progress every time. Do it step by step. - - -## Remarks -- The player object must be stored in a global variable called `player`. -- The function, method & property names should be __exactly__ as described above (for the tests to function). -- __Avoid code duplication!__ You are free to add as many extra functions as you like. -- Pay attention to edge-cases! Your code should throw errors when the user tries to do something invalid (delete a song that doesn't exist, etc.). -- You can use all the material you've learned so far, including extras you've learned on your own. -- Write your code in the `index.js` file. It contains a template which you can use as the basis for your code. \ No newline at end of file +this an MP3 with multi stuff u can do. +you can play or add or remove songs . +you can make new playlists with the songs you have in the player. +you can even search songs or playlits by their duration or query . +by ori davidi \ No newline at end of file From 22d6b8b39ae3954600e0abbf09b726050c928db7 Mon Sep 17 00:00:00 2001 From: oridavidi100 Date: Sat, 11 Sep 2021 22:05:39 +0300 Subject: [PATCH 39/39] Update index.js --- index.js | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index f437ba2..6bb3bff 100644 --- a/index.js +++ b/index.js @@ -53,13 +53,29 @@ const player = { } +// convert to mm:ss +function durationConvert(duration) +{ + let min = Math.floor(duration / 60); + let sec = duration % 60; + + if (min < 10){ + min = "0" + String(min); + } + if (sec < 10) { + sec = "0" + String(sec); + } + return min+':'+sec +} + function playSong(id) { - for (let i=0;i