Basic Javascript - how to remove a comma from the string

Asked

Viewed 805 times

-2

I have a question that is consuming me here concerning this little piece of code:

let word = "APPLE"
//CONVERTED TO ARRAY
let res = word.slice(3,5)
//RES = LE
let res1 = res.split("")
//REVERSE THE ARRAY NOW IS "E,L"
let res2 = res1.reverse()
//MERGE INTO A STRING
let res3 = res2.toString()
//FINALLY RETURN INTO "E L"

I want you to go out on the "E L" console, instead of "E,L," I want a space between the lyrics, I tried a lot of method and I couldn’t, please if anyone can help me I would be very grateful

  • 5

    It is not better to use .join(' ')?

  • Uncaught Typeerror: res3.Join is not a Function at <Anonymous>:1:6 this message appears on the console

  • 4

    IS res2.join...

1 answer

2


You must have used the .join('') wrong.

let res2 = ["E", "L"]
let res3 = res2.join(' ')
console.log(res3)

Functional code above.

inserir a descrição da imagem aqui

  • I’m going to put the full code here so you can take a closer look:

  • I put the functional code and gave this message on the console: VM116:1 Uncaught Referenceerror: res3 is not defined at <Anonymous>:1:1 (Anonymous) @ VM116:1

  • however it is completely right kkk, copies the code inside a new file. js

  • I put a print of the result I got

  • I am using the Liveserver plugin, now when I put any variable name is returning the following :Csskeywordvalue&#Xa] }

  • Thanks restarted the pc, created a new file and everything ran right, thank you!

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.