# Creating a function over multiple lines

I'm attempting to create a function over multiple lines.

# Parameters of the challenge:

1. Function returns 'barbarian'
2. Only 2 characters per line
3. 40 lines maximum. I keep trying to use a fat arrow to declare my function, but fat arrows don't seem to work if you don't have them connected.

My current work:

f=
(
)=>

'\
b\
a\
r\
b\
a\
r\
i\
a\
n\
s\
'


This works, but the ')=>' is 3 characters long. I really just want to know how it is possible to even stretch out the creation of a function. I can't find any info on it anywhere as it's obviously not very practical.

• Related? Mar 2 '18 at 23:35
• Welcome to PPCG! Unfortunately, this challenge does not have an objective winning criterion, and I am voting to close this challenge until rectified. In the future, please use the sandbox to receive feedback on your question before it is posted. Mar 2 '18 at 23:40
• Also Stack Overflow would be a better place for this, if worded differently Mar 2 '18 at 23:52
• I think this is fine as a question asking for tips to solve a particular code challenge and have voted to reopen. Mar 3 '18 at 4:03
• I agree with Laikoni that this is definitely asking for advice on dealing with a code layout constraint (i.e., restricted source) rather than asking a programming question like at SO.
– xnor
Mar 3 '18 at 4:09

# 35 Lines

f=
0[
c=
'\
c\
o\
n\
s\
t\
r\
u\
c\
t\
o\
r'
][
c]

r\
e\
t\
u\
r\
n\
'\
b\
a\
r\
b\
a\
r\
i\
a\
n'



Try it online!

Uses the fact that 0 is a number, the constructor of 0 is Number, and the constructor of Number is Function.

# 32 Lines

0[
c=
'\
c\
o\
n\
s\
t\
r\
u\
c\
t\
o\
r'
][
c]

f=
_\
=>
'\
b\
a\
r\
b\
a\
r\
i\
a\
n'
(
)


Try it online!

This essentially runs

Function(
f=
_=>
'barbarian')()


which uses the IIFE structure. Added bonus is that we can line-break some parts in the function body to reduce the line count.

# 24 Lines

f=
''
[
'\
t\
r\
i\
m'
][
'\
b\
i\
n\
d'
]
b\
a\
r\
b\
a\
r\
i\
a\
n


Try it online!

Inline version:

f=''['trim']['bind']
barbarian


Since all we want is to return a string, we can get away with a string method bound to a string. By using trim, we can also safely leave a beginning newline.

Here is a 38 line solution:

f=
[]
[
'\
m\
a\
p'
][
'\
c\
o\
n\
s\
t\
r\
u\
c\
t\
o\
r'
]
r\
e\
t\
u\
r\
n\
'\
b\
a\
r\
b\
a\
r\
i\
a\
n\
'


It creates a function using the Function constructor, which it accesses from [].map.constructor using subscript notation ([]['map']['constructor']). This is the method JSFuck uses to create functions.

• Are you not accessing []['map']['constructor'] instead of []['sum']['constructor']? Mar 3 '18 at 5:35
• Unless I'm reading this wrong, it returns 'barbarians' plural?
– cole
Mar 3 '18 at 5:36
• @cole The question's attempt -- contrary to the question's problem statement -- also seems to output the plural. Mar 3 '18 at 5:39
• >_< sorry typos Mar 3 '18 at 6:16
• This is great! Is there any way to shave it down to even fewer lines? Just curious at this point as this is the first I have heard of constructors. Mar 3 '18 at 17:51