Skip to content

Commit

Permalink
feat(playground): add an AskScript example (Facebook likes) (#384)
Browse files Browse the repository at this point in the history
  • Loading branch information
czerwinskilukasz1 authored Jul 16, 2020
1 parent c380a68 commit b1cc591
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/playground/public/assets/js/demosData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,40 @@ const demos: { [key: string]: Demo } = {
}`,
},

demo26: {
title: 'Facebook likes',
code: `// Below is a complete solution for a 6kyu Codewars task:
// https://www.codewars.com/kata/5266876b8f4bf2da9b000362
ask {
const likes = fun(names: array(string)): string {
const len = names:length
if (len == 0) {
return 'no one likes it';
}
if (len == 1) {
return concat(names[0], ' likes it');
}
if (len == 2) {
return concat(names[0], ' and ', names[1], ' like it');
}
if (len == 3) {
return concat(names[0], ', ', names[1], ' and ', names[2], ' like it');
}
return concat(names[0], ', ', names[1], ' and ', len-2, ' others like it');
}
[
likes([]),
likes(['Peter']),
likes(['Jacob', 'Alex']),
likes(['Max', 'John', 'Mark']),
likes(['Alex', 'Jacob', 'Mark', 'Max'])
]
}
`,
},

demo30: {
title: 'Query',
code: `ask {
Expand Down

0 comments on commit b1cc591

Please sign in to comment.