I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.
i have already tryed the primitive but it didn’t work
now i try with the constructor but it shows me an error
i cancelled the last str2= String
thank you anyway for your help
index 0: concatenates “U” onto the function String. This can’t be done, so error.
If you fix that, next issue is that you are using <= in the loop, so it tries to go from 0 to the length of the string. But strings are zero-indexed, the last index is one less than the length.
str2 is an empty string
index 0: concatenate “U” onto the string str2
index 1: concatenate “V” into the string str2
index 2: nothing there, so concatenate undefined onto the string str2. This can’t be done, so error.
Then if you fix that, you’re throwing away whatever you’ve done in the loop by assigning the function String to str2 once you’re finished, so the return value will always be that function
@DanCouper
i am sory if i say something stupid but i am really new.
i read everything you wrote but i don’t have any kind of error. everything works fine. If you console.log(str2) at the end you will have the right result. “FREE CODE CAMP”
but i understand i made an error in the declaration of the variabile because i can’t use it as a result
I don’t understand how it could possibly work: in the loop, you build a string. Then right at the bottom, that first line there, str2 = String overwrites everythng you’ve done.
Instead of returning the string you’ve built, you’re returning a function String, you’re just blowing away everything you did
You can put a console log in before that, and sure, it will show the string you’ve built, but the actual function can’t work
@DanCouper
I am really sorry. that was my last tryed. if you cancel that and console.log(str2) you have the right result but the test doesn’t accept it as answer and i can’t understand why.
@Marmiz
sorry, if i pasted a wrong attemp.
i would like to work on the “non letter” but it not usefull till i don’t understand why the first result it’s wrong.
run my js and see the result of the first FREE CODE CAMP.
Apologize if I was not clear @marcocbnet,
(once fixed the i variable) your code run fine for that specific case, but this doesn’t mean it’s enough to pass all the requirements set for the challenge.
@Marmiz the fact is
if you run the code, the software give me wrong even on FREE CODE CAMP
it means i am wrong with the variable not with the procedure. @ILM
i would love to work on the rest but the software when i run my program says i am wrong even in FREE CODE CAMP. it means i am wrong with the type of variable not with the procedure.
@ILM
i would love to work on the rest but the software when i run my program says i am wrong even in FREE CODE CAMP. it means i am wrong with the type of variable not with the procedure.