Coding for radicals

I am currently having student rewrite exponents as radicals and vice versa. I tried playing with the code but did not have any luck.1

Here is an example of what I am looking for. Any assistance with the code would be greatly appreciated. If possible I would prefer to use a table.

This is a code that I tried and it seems to work.
#=================================================
var1="\sqrt[{r1}]{x^{{exp1}}}"
var2=“x^{\frac{{exp1}}{{r1}}}”
#root is:
r1=3
#exponent is:
exp1=5

bool1= this.cellContent(1,2)=var2

cellContent(1,1):var1
cellContent(1,3): when bool1 “:white_check_mark:” otherwise var2
correct: bool1
#===========================================

This works for different roots and exponents over x. Just change the numbers and add boolean to each row.

Edit:
This parsed the code wrongly.
Activity that I tested