I can't find an error in the Javascript code

I wrote the source code for a new application on IOS, when writing there were no errors, but when I ran the code, an error appeared in this place:

 var t = readLine()!
var s = readLine()!
var len_s = s.count
var t_lis = Set(t)
var c_s   = Counter(s)
var c_t   = Counter(t_lis[len_s])
var c_res = [String: String]()
var summ  = 0
for e in c_s{
    c_res[e] = [c_s[e], min( c_s[e], c_t[e] )]
    summ += c_res[e][1]}
for i in (t.count-s.count) + 1 {
    if summ == len_s-1{
        print(i)
        break
        
    }
    if t[i] in c_res
            if c_res[t[i]][1] > 0{
            c_res[t[i]][1] -= 1
            summ -= 1
    }
    if i+len_s < t.count && t[i+len_s] in c_res
        if c_res[ t[i+len_s] ][1] < c_res[ t[i+len_s] ][0]{
            c_res[ t[i+len_s] ][1] += 1
            summ += 1
        
    }
    else
    print(-1)
        }
Who can tell what is wrong?
And does anyone know a quality service for code analysis? Which could make one code unique across multiple projects. Thanks in advance !

What language is this? That isn’t Java and it isn’t JavaScript.

It is JavaScript. This code writing on JavaScript language

First of all, you labeled this as “Java” - Java and JavaScript are two different languages.

Next, this is not valid JS. For example:

var t = readLine()!

What is that !? That is not valid JS. (Though, that could work in TS.)

And what is “readLine” Is this Node? Are there imported modules that you aren’t listed?


var t_lis = Set(t)

That is not how you declare a set in JS.


var c_s   = Counter(s)

What is “Counter”?


var c_res = [String: String]()

What the hell is that?


for e in c_s{

In JS this would require parentheses.


c_res[e] = [c_s[e], min( c_s[e], c_t[e] )]

What is “min”?


if summ == len_s-1

In JS this would require parentheses.


print(i)

What is “print”?


Do I need to go on? This is either not JS or it is very bad JS that would need a lot of fixing. If this is working, it’s not JS and if it’s JS it’s not working.

And you said:

I wrote the source code for a new application on IOS

You’re going to have to be clear about that. You don’t normally write iOS apps in JS, at least not native ones. What framework are you using? Is this just a web app that is being used on iOS?

We need a lot more information if we’re going to help you.

The code doesn’t work… I’m writing cross-platform. I understand that I need to completely rewrite the code

You still haven’t even identified the language or context.