Skip to main content

When updating value in an array, I am getting extra commas... and not sure that it's still indexed properly

  • December 30, 2020
  • 2 replies
  • 9 views

Forum|alt.badge.img+14

Hi there -

When I run this code, I am getting extra commas and the values are not lining up. What am I doing wrong?

let vowels = “aeiou”
let sentence = “Your bumpkin is so beautiful”

let mda=
let fullsetofzeros =
var i
var j

for (i = 0; i < vowel.length; i++) { // p1
mda[i] = 0
}

for (i= 0; i < sentence.length; i++) { // p1
fullsetofzeros.push(mda)
}

output.text( Matrix of zeroes ${fullsetofzeros} )

for (i= 0; i < vowel.length; i++) { // p1
for (j= 0; j < sentence.length; j++) { // p1
if (vowel.includes(sentence[j])) {
fullsetofzeros[i][j]= 1
}
}
}

output.text( Matrix after test ${fullsetofzeros} )

2 replies

kuovonne
Forum|alt.badge.img+29
  • Brainy
  • 6009 replies
  • December 30, 2020

Can you provide the output you are getting and your expected output?

You declare a variable vowels with an s at the end and later reference a vowel vowel without an s at the end. Is there additional code you did not include in your post?


Justin_Barrett
Forum|alt.badge.img+21
  • Inspiring
  • 4647 replies
  • December 31, 2020

This is already being discussed in another thread: