convert from python to javascript online code example

Example 1: convert js to python online

>>> import js2py
>>> f = js2py.eval_js('function f(x) {return x + x}')
>>> f(2)
4
>>> f()
nan
>>> f(f)
function f(x) { [python code] }function f(x) { [python code] }

Example 2: convert from python to javascript online

def choose_best_sum(t, k, ls):
    most = 0

    for i in range(len(ls)-1):
        addN = 0
        if i +k > len(ls) - 1:
            break
        for j in range(i,i+k-1):
            addN += ls[j]
        for p in range(i+k-1,len(ls)-1):
            addN += ls[p]
            if addN > most and addN <= t:
                most = addN
                addN -= ls[p]
            else:
                addN -= ls[p]
    if most == 0:
        return None
    return most