From 4d7140d4e2275e47e5b2832a82498ac6241689bb Mon Sep 17 00:00:00 2001 From: andy2124 Date: Tue, 4 Oct 2022 19:03:30 -0700 Subject: [PATCH 1/2] saving --- code/Andy/javascript/nums_redo_vue/nums.html | 118 +++++++++++++++++++ code/Andy/javascript/nums_redo_vue/nums.js | 106 +++++++++++++++++ 2 files changed, 224 insertions(+) create mode 100644 code/Andy/javascript/nums_redo_vue/nums.html create mode 100644 code/Andy/javascript/nums_redo_vue/nums.js diff --git a/code/Andy/javascript/nums_redo_vue/nums.html b/code/Andy/javascript/nums_redo_vue/nums.html new file mode 100644 index 00000000..da99480a --- /dev/null +++ b/code/Andy/javascript/nums_redo_vue/nums.html @@ -0,0 +1,118 @@ + + + + + + + + + + + + + +
+ + + +
+ + + +
+ {{ userinput }} + + + {{ result }} + +
+
    +
  • {{ num }}
  • +
+
    +
  • {{ index }}) {{ num }}
  • +
+
+
+
    +
  • {{ ten }}
  • +
+
    +
  • {{ index }}) {{ ten }}
  • +
+
+
+
    +
  • {{ hundred }}
  • +
+
    +
  • {{ index }}) {{ hundred }}
  • +
+
+
+ + + + + + + + + \ No newline at end of file diff --git a/code/Andy/javascript/nums_redo_vue/nums.js b/code/Andy/javascript/nums_redo_vue/nums.js new file mode 100644 index 00000000..5fa6e2ed --- /dev/null +++ b/code/Andy/javascript/nums_redo_vue/nums.js @@ -0,0 +1,106 @@ +// var app = new Vue({ +// el: '#app', +// data: { // data object +// userinput: '', //user key +// number : 6, + + + + +// }, +// methods: { +// convertNum: function(){ +// this.number > userinput +// } +// }, +// created: function() { + +// } +// }) +let app = new Vue({ + // query selector of the html element representing the app + el: '#app', + // app data + // data stored with the app + // for displaying in the page: {{message}} + // for getting input from the user: v-model="message" + // for modifying in methods: this.message + data: { + userinput: '', + result: 0, + // return , + low_numbers: { + 0: "zero", + 1: "one", + 2: "two", + 3: "three", + 4: "four", + 5: "five", + 6: "six", + 7: "seven", + 8: "eight", + 9: 'nine', + 10: 'ten', + 11: 'eleven', + 12: 'tweleve', + 13: 'thirteen', + 14: 'fourteen', + 15: 'fifteen', + 16: 'sixteen', + 17: 'seventeen', + 18: 'eighteen', + 19: 'nineteen', + }, + tens: { + 20: "twenty", + 30: "thirty", + 40: "forty", + 50: "fifty", + 60: "sixty", + 70: "seventy", + 80: "eighty", + 90: "nintey", + }, + hundreds: { + + 100: "one hundred", + 200: "two hundred", + 300: "three hundred", + 400: 'four hundred', + 500: 'five hundred', + 600: 'six hundred', + 700: 'seven hundred', + 800: 'eight hundred', + 900: 'nine hundred', + }, + + + }, + // app methods + // can be called from events in the page: v-on:click="method" + // can be called from other methods: this.method() + // can be called from outside the app: app.method() + methods: { + convert: function (event) { + let result + let user = this.userinput + console.log(user, 'user') + const expr = user >= 20; + switch (expr){ + case 'case 1 ': + console.log('number greater than 20') + break; + } + // let result = this.low_numbers[user] + // this.result = this.result + this.result = this.low_numbers[user] + console.log(this.low_numbers[user],'testing' ) + this.userinput = '' + return result + }, + }, +}) + + // created - a lifecycle hook + // called when the app is created + // useful for setting up app data From 149f70d5546718b642c352c48e1168370fbeafef Mon Sep 17 00:00:00 2001 From: andy2124 Date: Wed, 5 Oct 2022 18:37:46 -0700 Subject: [PATCH 2/2] saving --- code/Andy/javascript/nums_redo_vue/nums.js | 62 +++++++++++++--------- 1 file changed, 38 insertions(+), 24 deletions(-) diff --git a/code/Andy/javascript/nums_redo_vue/nums.js b/code/Andy/javascript/nums_redo_vue/nums.js index 5fa6e2ed..dc4c4e43 100644 --- a/code/Andy/javascript/nums_redo_vue/nums.js +++ b/code/Andy/javascript/nums_redo_vue/nums.js @@ -52,26 +52,26 @@ let app = new Vue({ 19: 'nineteen', }, tens: { - 20: "twenty", - 30: "thirty", - 40: "forty", - 50: "fifty", - 60: "sixty", - 70: "seventy", - 80: "eighty", - 90: "nintey", + 2: "twenty", + 3: "thirty", + 4: "forty", + 5: "fifty", + 6: "sixty", + 7: "seventy", + 8: "eighty", + 9: "nintey", }, hundreds: { - 100: "one hundred", - 200: "two hundred", - 300: "three hundred", - 400: 'four hundred', - 500: 'five hundred', - 600: 'six hundred', - 700: 'seven hundred', - 800: 'eight hundred', - 900: 'nine hundred', + 1: "one hundred", + 2: "two hundred", + 3: "three hundred", + 4: 'four hundred', + 5: 'five hundred', + 6: 'six hundred', + 7: 'seven hundred', + 8: 'eight hundred', + 9: 'nine hundred', }, @@ -83,18 +83,26 @@ let app = new Vue({ methods: { convert: function (event) { let result + let lastOne let user = this.userinput - console.log(user, 'user') - const expr = user >= 20; - switch (expr){ - case 'case 1 ': - console.log('number greater than 20') - break; - } + // userTwo = user + console.log(typeof(parseInt(user)), 'user') // let result = this.low_numbers[user] // this.result = this.result this.result = this.low_numbers[user] + lastOne = user.slice(-1) + console.log(lastOne, 'last one') + // 654 : 654/10 = 65.4 /10 = 6.54 how we get the 6 for hundreds digit + hundredsDigit = parseInt((user/10)/10) + // 654/10 = 65.4 /10 = 6.54 % 10= + unitsDigit = parseInt(((user/10)%10)) + console.log(unitsDigit, 'units digit') + console.log(hundredsDigit, 'testing hundreds digit') + console.log(user,'testing users') console.log(this.low_numbers[user],'testing' ) + console.log(this.low_numbers[lastOne],'testing v2' ) + console.log(this.tens[unitsDigit],'testing v2' ) + console.log(this.hundreds[hundredsDigit],'testing v2' ) this.userinput = '' return result }, @@ -104,3 +112,9 @@ let app = new Vue({ // created - a lifecycle hook // called when the app is created // useful for setting up app data + + // tens_digit = number // 10 + // new_tens = tens_digit % 10 + // ones_digit = number % 10 + // tens_word = ten[new_tens] + // ones_word = low_numbers[ones_digit] \ No newline at end of file