javascriptpractice:Arrays,Loops,Objects,Iterators practice intermediate javascrpit concepts with these 3 code challenges

i had create this code fo the function of subLength challenge but the code still return me ‘character is not includes in string’ can someone help me please:
const subLength = (string, char) => {

let count = ;

for(let i = 0; i < string.length; i++) {

if (string[i] === char) {


if(count.length > 2 || count.length < 2) {

return 0;


return count[1]


return 'character is not include in string'




Hey @method3884535642, it’s great that you’re seeking help.

Here’s a topic that will help us help you, give it a shot :wink:

How to create a topic that everyone will read

Just adjust it according to the topic above and it will be super easy to help you! :slight_smile:

It really depends on whether you want the counter to be an array of chars or an integer that just increments each time it finds a char in a string. Which one do you want?

Overall it seems like your curly brackets ‘{’ and ‘}’ are a little bit off. That’s where proper code formatting comes in.

For example the code in your post should be formatted like this:

let counter = 0;

for(let i = 0; i <= 10; i++) {
  if(i === 4) {
    console.log('4 is my favorite number!');

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.