Need some help on array

var name = “jackie chan”;

// i created function to convert string into array
function convert (word 1){
return name.split();
var converted = console.log(convert(hello));
// now i wanted to reverse the array and also convert array to string again


// convert array to string
function convertBack(word 2){
return convert.tostring()
// but i am not getting the result can anyone suggest where i went wrong


Try taking your code step by step and don’t continue until your code is doing as expected in the first steps.

I show you my solution and hope it works out for you.

var name = "jackie chan"; function convert (str) { return str.split(" "); // You must indicate at which point of the string you want to split your string. In this case at the space " "; } let converted = convert('hello world'); // Call the function, and store it in a variable. console.log(converted) // [ 'hello', 'world' ] let reversed = converted.reverse(); console.log(reversed); // [ 'world', 'hello' ] function convertBack(arr) { return arr.toString(); } console.log(convertBack(reversed)); // world,hello

First, there can’t be a space in a variable name, so word 1 should be word1
And, then the parameter used would be word1 while the variable used inside the function is name.
These should be the same variable;
so change both to word1 or change both to name