Skip to content

Commit e94f5b0

Browse files
committed
add recipe Creating a String from an Array
1 parent b746ee1 commit e94f5b0

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
layout: recipe
3+
title: Creating a String from an Array
4+
chapter: Arrays
5+
---
6+
## Problem
7+
8+
You want to create a string from an array.
9+
10+
## Solution
11+
12+
Use JavaScript's Array toString() method:
13+
14+
{% highlight coffeescript %}
15+
["one", "two", "three"].toString()
16+
# => 'three,two,one'
17+
{% endhighlight %}
18+
19+
## Discussion
20+
21+
`toString()` is a standard JavaScript method. Don't forget the parentheses.

wanted-recipes.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ evens.every even
3333
* Filtering arrays # [1..10.filter (x) -> x % 2 == 0 # => [ 2, 4, 6, 8, 10 ]
3434
* Detecting presence of matching items in an array # [1..10].some (x) -> x % 2 == 0 # => true
3535
* Processing an array item by item # [10..1].forEach (x) -> console.log x # => nothing;, but a countdown is displayed on the console
36-
* Creating a string from an array
3736
* Replace all duplicates of an array
3837

3938
## Dates and Times

0 commit comments

Comments
 (0)