4/15 need help


#1

my code
s=0
n=raw_input("n=")
while int(n)<0:
n=raw_input("n=")
def degit_sum(n):

for i in len(n):
    s+=int(i)
print s
return s

but it doesn't work


#2

You can't iterate through an int, from my understanding. I got around this by converting the original input value to a string, then iterating through that string, converting each digit back to an int inside of the loop


#3

It is // here we define our method using "this", before we even introduce bob
var setAge = function (newAge) {
this.age = newAge;
};
// now we make bob
var bob = new Object();
bob.age = 30;
// and down here we just use the method we already made
bob.setAge = setAge;

// change bob's age to 50 here
setAge(50);