Question: I've console.log'd the data being returned from my API and I get: 

```
​
fetchedData: {…}
​​
confirmed: Object { value: 7650696, detail: "https://covid19.mathdro.id/api/confirmed" }
​​
deaths: Object { value: 425869, detail: "https://covid19.mathdro.id/api/deaths" }
​​
lastUpdate: "2020-06-13T04:33:11.000Z"
​​
recovered: Object { value: 3630249, detail: "https://covid19.mathdro.id/api/recovered" }
​​
<prototype>: Object { … }
​
<prototype>: Object { … }

```

Then, when I `console.log(data.confirmed)` I receive undefined, even though it's listed right there. I'm using hooks in my app, though I'm not sure that has anything to do with it because I'm able to console the data just fine. The problem is when I try to access the properties in data. 

<https://codesandbox.io/s/wizardly-banzai-2n2xq?file=/src/App.js>

Answer: 
Not to spoil your assignment, but regex replacement offers a very concise way to do this:

```
String input = "tcagdo";
String output = input.replaceAll("(.)(..)", "$2$1");
System.out.println(output);

```

The regex pattern `(.)(..)` matches three characters at a time, capturing the first and last two in separate capture groups. The replacement then splices together the groups using the ordering you want.
```
public static void main(String[] args) {
    System.out.println(oneTwo("tcagdo"));
}

private static String oneTwo(String str) {
    if (str.length() < 3) return "";
    char[] res = str.toCharArray();
    for (int j = 0; j < res.length; j += 3){
        if (j + 3 > res.length) {
            break;
        } else {
            char temp = res[j];
            res[j] = res[j + 1];
            res[j + 1] = res[j + 2];
            res[j + 2] = temp;
        }
    }
    return String.valueOf(res);
}

```

Just a simple 3-way swap using a `temp` variable with an additional check if the `length` is not divisible by 3.

`char[]` array is better for swapping elements because `Strings` are immutable in `Java`.