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
| import React, { Component } from 'react'; | |
| class ChatBox extends Component { | |
| constructor() { | |
| super(); | |
| this.state = { | |
| maintainState: 'here' | |
| } | |
| } |
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
| class Columns extends React.Component { | |
| render() { | |
| return ( | |
| <React.Fragment> | |
| <td>Hello</td> | |
| <td>World</td> | |
| </React.Fragment> | |
| ); | |
| } | |
| } |
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
| render() { | |
| // React does *not* create a new div. It renders the children into `domNode`. | |
| // `domNode` is any valid DOM node, regardless of its location in the DOM. | |
| return ReactDOM.createPortal( | |
| this.props.children, | |
| domNode, | |
| ); | |
| } |
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
| "<table> | |
| <tr> | |
| <td>Hello</td> | |
| <td>World</td> | |
| </tr> | |
| </table>" |
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
| // Input: [ 2, 7, 11, 15 ] | |
| //* Use a nested for loop | |
| //* compare the current num(i) to the next num(k++) and check if they match | |
| //* if they match then return both indices in an array | |
| // Output: [ 0, 1 ] | |
| // edge cases: ?? |
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 twoSum = function(nums, target) { | |
| let indicesArray = []; | |
| for (let i = 0; i < nums.length; i++) { | |
| for (let k = i + 1; k < nums.length; k++) { | |
| if (nums[i] + nums[k] === target) { | |
| indicesArray.push(i, k) | |
| } | |
| } | |
| } | |
| return indicesArray; |
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 twoSum = function(nums, target) { | |
| let dictionary = {} | |
| let complementValue = 0; | |
| let indicesArray = []; | |
| for (let i = 0; i < nums.length; i++) { | |
| complementValue = target - nums[i]; | |
| if (dictionary.hasOwnProperty( complementValue )) { | |
| return indicesArray = [ dictionary[complementValue], i ] | |
| } |
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
| const myWorkSchedule = { | |
| monday: '10-5', | |
| tuesday: '10-5', | |
| friday: '11-9' | |
| } | |
| const updatedSchedule = Object.assign({}, myWorkSchedule, { thursday: '8-5' }) | |
| updatedSchedule | |
| // {monday: "10-5", tuesday: "10-5", friday: "11-9", thursday: "8-5"} |
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
| const myWorkSchedule = { | |
| monday: '10-5', | |
| tuesday: '10-5', | |
| friday: '11-9' | |
| } | |
| const updatedSchedule = { thursday: '11-6', ...myWorkSchedule } | |
| updatedSchedule | |
| // {thursday: "11-6", monday: "10-5", tuesday: "10-5", friday: "11-9"} |
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
| def sorcery | |
| controller_name = params['controller'] | |
| controller_name.chop! | |
| model_name = controller_name.capitalize | |
| instance_variable_set('@' + controller_name, Object.const_get( model_name ).find_by(id: params[:id])) | |
| end |
OlderNewer