No output is showing in active learning , Arrays - Learn web development | MDN

i was trying to solve the following using multidimensional array but its not working.
This is the problem
i tried everything , so please could you tell me what is the error in my code.
i don’t know how to create this iframe in codepen. so i am pasting the code here.


const list = document.querySelector(’.output ul’);

const totalBox = document.querySelector(’.output p’);

let total = 0;

list.innerHTML = ‘’;

totalBox.textContent = ‘’;

// number 1

let products = [‘Underpants:6.99’,‘Socks:5.99’,

            'T-shirt:14.99',

            'Trousers:31.99',

            'Shoes:23.99'];

for (let i = 0; i < products.length; i++) { // number 2

// number 3

products[i] = products[i].split(:); //splitting and storing sub array in products[i]

products[i][1] = Number(products[i][1]); //making prices string to number and replacing it with itself

// number 4

total+=products[i][1]; // calculating total of all prices

// number 5

let itemText = products[i][0]+’–$’+products[i][1]; //storing the name + --$ price

const listItem = document.createElement(‘li’);

listItem.textContent = itemText;

list.appendChild(listItem);

}

totalBox.textContent = ‘Total: $’ + total.toFixed(2);


This is the complete iframe code including the predefined code too.

Thank You

Hello @Mad2000

you doing great just missed aa tiny thing which i think it typo

this line

products[i] = products[i].split(:); 

should be

products[i] = products[i].split(":");  // you can use single or double quote 

make sure that all those single quote are using

' '  not ``

cause i am not sure if that what was made by you or this site as it tend to change the quote when you paste it here to overcome that surrond your code with triple ` before and after it

hope that help and have a nice day :slight_smile:

a simple typo ! the are annoying
Yes that was the error.
thanks for the help.

you very welcome :slight_smile: