Created
January 4, 2018 21:53
-
-
Save garybunofsky/cfc97758639951e6155c845c2749dae3 to your computer and use it in GitHub Desktop.
// source https://jsbin.com/biwezom
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
<script id="jsbin-javascript"> | |
var user = { | |
first: 'Tony', | |
middle: 'The', | |
last: 'Tiger', | |
phone: '440-349-2943', | |
type: 'admin', | |
active: 1 | |
} | |
// Answer 1. | |
//function deactivate(user) { | |
// user.active = 0; | |
// return user; | |
//} | |
//console.log(deactivate(user)); | |
// Answer 2 | |
//function toggleActive(user){ | |
// return user.active = !user.active;; | |
//} | |
//console.log(toggleActive(user)); | |
// Answer 3 | |
//function formatPhone(user) { | |
// var newPhone = ''; | |
// for(var i = 0; i < user.phone.length; i++){ | |
// if(user.phone[i] != '-') { | |
// newPhone += user.phone[i]; | |
// } | |
// } | |
// return newPhone; | |
//} | |
//console.log(formatPhone(user)); | |
// Questions | |
// | |
// 1. Write function called deactivate that changes the user's 'active' | |
// property to true to false. | |
// | |
// 2. Write a function called toggleActive, that changes the user's 'active' | |
// property to the opposite. For instance, if it's true, make it false; | |
// if it's false, make it true. | |
// 3. Write a function called format phone that removes all dashes from a user's phone number. | |
// For instance 216-867-5309 should be formatted as 2168675309 | |
// | |
// | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">var user = { | |
first: 'Tony', | |
middle: 'The', | |
last: 'Tiger', | |
phone: '440-349-2943', | |
type: 'admin', | |
active: 1 | |
} | |
// Answer 1. | |
//function deactivate(user) { | |
// user.active = 0; | |
// return user; | |
//} | |
//console.log(deactivate(user)); | |
// Answer 2 | |
//function toggleActive(user){ | |
// return user.active = !user.active;; | |
//} | |
//console.log(toggleActive(user)); | |
// Answer 3 | |
//function formatPhone(user) { | |
// var newPhone = ''; | |
// for(var i = 0; i < user.phone.length; i++){ | |
// if(user.phone[i] != '-') { | |
// newPhone += user.phone[i]; | |
// } | |
// } | |
// return newPhone; | |
//} | |
//console.log(formatPhone(user)); | |
// Questions | |
// | |
// 1. Write function called deactivate that changes the user's 'active' | |
// property to true to false. | |
// | |
// 2. Write a function called toggleActive, that changes the user's 'active' | |
// property to the opposite. For instance, if it's true, make it false; | |
// if it's false, make it true. | |
// 3. Write a function called format phone that removes all dashes from a user's phone number. | |
// For instance 216-867-5309 should be formatted as 2168675309 | |
// | |
//</script> |
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 user = { | |
first: 'Tony', | |
middle: 'The', | |
last: 'Tiger', | |
phone: '440-349-2943', | |
type: 'admin', | |
active: 1 | |
} | |
// Answer 1. | |
//function deactivate(user) { | |
// user.active = 0; | |
// return user; | |
//} | |
//console.log(deactivate(user)); | |
// Answer 2 | |
//function toggleActive(user){ | |
// return user.active = !user.active;; | |
//} | |
//console.log(toggleActive(user)); | |
// Answer 3 | |
//function formatPhone(user) { | |
// var newPhone = ''; | |
// for(var i = 0; i < user.phone.length; i++){ | |
// if(user.phone[i] != '-') { | |
// newPhone += user.phone[i]; | |
// } | |
// } | |
// return newPhone; | |
//} | |
//console.log(formatPhone(user)); | |
// Questions | |
// | |
// 1. Write function called deactivate that changes the user's 'active' | |
// property to true to false. | |
// | |
// 2. Write a function called toggleActive, that changes the user's 'active' | |
// property to the opposite. For instance, if it's true, make it false; | |
// if it's false, make it true. | |
// 3. Write a function called format phone that removes all dashes from a user's phone number. | |
// For instance 216-867-5309 should be formatted as 2168675309 | |
// | |
// |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment