This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
reverse('hello') === 'olleh' | |
reverse('world!') === '!dlrow' | |
reverse('JavaScript') === 'tpircSavaJ' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function reverse(string) { | |
let answer = string.split('') // step 1 | |
answer.reverse() // step 2 | |
answer = answer.join('') // step 3 | |
return answer //step 4 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function reverse(string) { | |
return string.split('').reverse().join('') | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function reverse(string) { | |
return [...string].reverse().join('') | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function reverse(string) { | |
let reversed = '' // step 1 | |
for(let char of string) { // step 2 | |
reversed = char + reversed; // step 3 | |
} | |
return reversed; // step 4 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function reverse(string) { | |
return string.split('').reverse().join('') | |
} | |
reverse('JS is fun! 😄') | |
// => �� !nuf si SJ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function reverse(string) { | |
return Array.from(str).reverse().join("") | |
} | |
reverse('JS is fun! 😄') | |
// => 😄 !nuf si SJ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Movie | |
attr_accessor :in_progress | |
attr_reader :title, :length, :budget | |
def title=(new_title) | |
if @in_progress | |
@title = new_title | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Movie | |
attr_accessor :finalized | |
attr_reader :title, :length, :budget | |
def title=(new_title) | |
if not @finalized | |
@title = new_title | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Movie | |
attr_accessor :finalized | |
attr_reader :title, :length, :budget | |
def title=(new_title) | |
unless @finalized | |
@title = new_title | |
end | |
end | |
end |
OlderNewer