Just getting started with arrays and could use some assistance!
const array =["ron","rexona","danzial","alexander"];
Q1 - Create a function that will return an array
containing
items from array
with more than 4 characters.
['alaska','orlando','phoenix','orlando','alaska'];
Q2 - Write a function that takes an array
of states and generates
an object displaying the occurrence of each state.
{
alaskaa: 2,
phoenix: 1,
orlando: 2,
}
Here's my attempt:
enter code here
<script>
var i, len, pc;
var name=["ron","rexona","danzial","alexander"];
len = name.length;
function test() {
for (i = 0; i<len; i++) {
pc += name[i];
}
}
console.log(pc);
</script>