• challenge #1 - #6 update 06/03 at 2017年07月18日

    准备学ruby的前端,还在下ubuntu。先随便写写

    challenge #1 easy

    // Create a program that will ask the users name and username, age. have it tell them the information back, in the format
    const fs = require('fs')
    const readline = require('readline')
    let name, age, username, text
    let rl = readline.createInterface({
        input: process.stdin,
        output: process.stdout
    })
    function puts(str, callback) {
        rl.question(str + '\n', (answer) => {
            callback(answer)
        })
    }
    puts('your name?', (answer) => {
        name = answer
        puts('your age?', (answer) => {
            age = answer
            puts('your username?', (answer) => {
                username = answer
                text = ` Your name is ${name}\n You are ${age} old \n Your username is ${username}`
                fs.writeFile('./test.txt', text, function (err) {
                    if (err) {
                        throw err;
                    }
                    console.log(text)
                    rl.close()
                })
            })
        })
    })
    rl.on("close", () => {
        process.exit(0)
    })
    
    
  • 这种一般都是自己写吧,需求不复杂的话其实就是一个特殊一点的表单。控件用ui框架里的就好了