This file contains hidden or 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
| var data = {"results":[{"answers":{"text":"A1"},"confidence":0.5,"name":"N1"},{"answers":{"text":"A2","type":"text"},"confidence":0.4,"name":"N2"},{"answers":{"text":"A3","type":"text"},"confidence":0.3,"name":"N3"},{"answers":{"text":"A4","type":"text"},"confidence":0.2,"name":"N4"},{"answers":{"text":"A5","type":"text"},"confidence":0.1,"name":"N5"}]}; | |
| // Version 1 | |
| var output = data.results.filter(ans => ans.confidence>0.2).map(ans => ({answer:ans.name,confidence:ans.confidence})); | |
| // Version 2 | |
| var output = data.results.reduce((f,s)=>{ | |
| if(s.confidence > 0.2) f.push({answer:s.name,confidence:s.confidence}) | |
| return f; | |
| },[]); | |
| // version 3 | |
| var output = data.results.reduce((f,s)=> s.confidence > 0.2? [...f,{answer:s.name,confidence:s.confidence}] :f,[]); |
This file contains hidden or 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
| //https://triin.net/2010/01/13/Fighting_the_uglyness_of_Array.push() | |
| var buttons = [ | |
| new OpenButton(), | |
| isPayingCustomer() ? new ExportButton() : null, | |
| new SaveButton(), | |
| new DeleteButton() | |
| ].compact(); | |
This file contains hidden or 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
| module.exports = env => { | |
| entry:'filename.js', | |
| output: { | |
| filename: "[name].bundle.js", | |
| path: path.resolve(__dirname, "dist") | |
| }, | |
| module: { | |
| rules: [ | |
| { | |
| test: /\.m?js$/, |
OlderNewer