+= 2 increments by 2
public static int loopIt(String str) {
int result = 0;
for (int i = 0; i < str.length(); i++) {
result += 2;
}
return result;
}
| Function Call | Return Value | |||
|---|---|---|---|---|
| loopIt("hello") | → | |||
| loopIt("world") | → | |||
| loopIt("apples") | → | |||
| loopIt("") | → | |||
| loopIt("a") | → | |||
| loopIt("oof") | → | |||
Experiment with this code on Gitpod.io