Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

算法必知必会:字符串反转 #36

Open
pengjielee opened this issue Oct 31, 2019 · 0 comments
Open

算法必知必会:字符串反转 #36

pengjielee opened this issue Oct 31, 2019 · 0 comments

Comments

@pengjielee
Copy link
Owner

实现1:

const reverse1 = ( str ) => {
	return str.split('').reverse().join('')
}

实现2:

const reverse2 = ( str ) => {
	let result = '';
	for( let char of str ){
		result = char + result
	}
	return result
}

实现3:

const reverse3 = ( str ) => {
	return str.split('').reduce( (result,char) => char + result );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant