From 70d1d874f6c253d13c9320f9c16481a7a5874f36 Mon Sep 17 00:00:00 2001 From: Amid Dadgar Date: Fri, 6 Oct 2017 17:05:26 +0330 Subject: [PATCH] Fix for replacing the middle item in an Array the provided code `styles[(styles.length - 1) / 2] = "Classics";` will replace the last item instead of the middle one. in order to fix that we need to change code like this : `styles[Math.floor((styles.length - 1) / 2)] = "Classics";` --- 1-js/05-data-types/04-array/2-create-array/solution.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/05-data-types/04-array/2-create-array/solution.md b/1-js/05-data-types/04-array/2-create-array/solution.md index 24351434..eec9055e 100644 --- a/1-js/05-data-types/04-array/2-create-array/solution.md +++ b/1-js/05-data-types/04-array/2-create-array/solution.md @@ -3,7 +3,7 @@ ```js run let styles = ["Jazz", "Blues"]; styles.push("Rock-n-Roll"); -styles[(styles.length + 1) / 2] = "Classics"; +styles[Math.floor((styles.length - 1) / 2)] = "Classics"; alert( styles.shift() ); styles.unshift("Rap", "Reggie"); ```