๐ŸŽ‰ Casts from the community

The latest and greatest from our community!

    import Vue from 'vue';
    
    new Vue({ 
        el: '#app',
        data: {
            message: 'Hello world'
        }
    });
    
    <html>
        <head>
            <link rel="stylesheet" href="index.css">
        </head>
        <body>
            <h1>index.html</h1>
            <script src="index.pack.js"></script>
        </body>
    </html>
    
    # If you're cooking a mushroom soup, go to step 5. 
    
    if mushroomSoup:
        print("go to step 5")
    # else:
    #     print("continue normally.")
    console.log("Hello from JavaScript");
    // JS Conventions
    
    // casing - camelCased
    
    var myLocationIsInUtah = true
    
    // white space
    
    for(var i = 0; i < 10; i++){
        
    }
    
    // naming
    
    var name = 10
    
    var age
    
    var friends
    
    var isThirsty
    
    var address
    
    code = "alot of code" 
    
    test = "this code"
    
    print(test)
    
    
    
    
    # from browser import document
    
    # def message():
    #     print("Hello with Brython!")
        
    # document.getElementById("btn").bind("click", message)
    
    # For general scripting
    # name = input('Enter your name:')
    # print('Hello ' + name)
    
    x = lambda v : v * 10
    print(x(5))
    
    article {
        background-color: khaki;
        margin: 2rem auto;
        max-width: 33rem;
        padding: 1rem;
    }
    
    section {
        background-color: rgba( 255, 255, 255, .3 );
        padding: 1rem;
        position: relative;
    }
    
    h2 {
    print(1 2)
    
    print(1  2)
    
    print(1 == 2)
    
    print(1 != 2)
    
    print(1 = 2)
    
    print(1  2)
    
    
    a {
        color: chocolate;
        text-decoration: none;
    }
    
    a:visited {
        color: orangered;
    }
    
    a:hover {
        background-color: lightpink;
        color: blueviolet;
    }
    
    <!DOCTYPE html>
    <html lang="en-us">
    
    <head>
    
    	<meta charset="UTF-8">
    	<meta name="viewport" content="width=device-width, initial-scale=1">
    
    	<title>Page Title</title>
        
        <link rel="stylesheet" href="style.css">
    </head>
    
    <body>
    .article-image {
        float: left;
        margin: 0 1rem 1rem 0;
    }
    
    h2 {
        clear: right;
    }
    .wrapper {
        max-width: 30rem;
    }
    
    img {
        max-width: 100%;
    }
    <!DOCTYPE html>
    <html lang="en-us">
    
    <head>
    
    	<meta charset="UTF-8">
    	<meta name="viewport" content="width=device-width, initial-scale=1">
    
    	<title>Page Title</title>
        
        <link rel="stylesheet" href="style.css">
        
    </head>
    <body>
    // register email and password to firebase
    export function registerUser(email, password) {
        firebase.auth().createUserWithEmailAndPassword(email, password)
            .then(cred => {
                console.log("User successfully created!");
                // clear inputs
                document.getElementById('login').value = '';
                document.getElementById('password').value = '';
            }).catch(err => {
                console.log(err.message);
            })
    }
    
    // log into app
    body {
        margin: 0;
        height: 100vh;
        display: flex;
        align-items: center;
        justify-content: center;
        background-image: linear-gradient(bisque, lightcyan);
    }
    
    .container {
        width: 100%;
    }
    
    .word {
    // JavaScript - Palindrome Checker
    
    // madam - is a palindrome
    // scrimba - is not a palindrome
    
    function isPalindrome(str) {
        return str === str.split('').reverse().join('');
    }
    
    console.log(isPalindrome('madam'));
    console.log(isPalindrome('scrimba'));
    console.log(isPalindrome('racecar'));
    .container {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(2, auto);
        g
    }
    
    .element {
        display: grid;
        grid-row: span 2;
        grid-template-rows: subgrid;
    }
    // creation of object for neural network
    function createNetworkObject(r,g,b){
    	let networkObject = {r:null, g:null, b:null};
    	networkObject.r = r/255;
    	networkObject.g = g/255;
    	networkObject.b = b/255;
    
    	return networkObject;
    }
    // Machine learning probability label - determining the result
    function networkLabel(result){
    	if(result.light > result.dark){
    			result = 'light';
    		} else {
    html {
        --color-primary: #b22222;
        
        --size-large: 3.5rem;
    }
    
    @media ( min-width: 400px ) {
        
        html {
            --color-primary: green;
            
            --size-large: 5rem;
        }
        
    import Vue from 'vue';
    import Vuex from 'vuex';
    
    Vue.use(Vuex);
    
    const store = new Vuex.Store({
        state: {
            count: 0
        },
        mutations: {
            increment (state) {
                state.count++
            }
        }
    // How to get started - Chatkit documentation for JS can be found at:
    // https://pusher.com/docs/chatkit/quick_start/javascript
    
    const tokenProvider = new Chatkit.TokenProvider({
      url: "https://us1.pusherplatform.io/services/chatkit_token_provider/v1/d3449670-b38c-4ecb-bc76-14ca778e1138/token"
    });
    
    
    const chatManager = new Chatkit.ChatManager({
      instanceLocator: "v1:us1:d3449670-b38c-4ecb-bc76-14ca778e1138",
      userId: "test", 
      tokenProvider: tokenProvider
    });
    
    /* Basic styles to make things pretty */
    body {
        margin: 0;
        font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    }
    
    .hero, .animatable {
        background: #f9f9f9;
        height: 100vh;
        display: flex;
        justify-content: center;
        align-items: center;
    }
    
    function shuffle (src) {
      const copy = [...src]
    
      const length = copy.length
      for (let i = 0; i < length; i++) {
        const x = copy[i]
        const y = Math.floor(Math.random() * length)
        const z = copy[y]
        copy[i] = z
        copy[y] = x
      }
    
      if (typeof src === 'string') {
        return copy.join('')
    // javascript
    
    var activeIcon = document.getElementById('home')
    
    // Create a function that takes an icon and sets it to active
    var setIconActive = function(icon) {
        // We should add the active class to new active icon
        icon.classList.add('active')
    // We should remove the active class from the old active icon
        activeIcon.classList.remove('active')
    // We should set the activeIcon variable to the new active icon
        activeIcon = icon
    }
    
    import {Todo} from './store'
    
    tag App
    	prop todos
    
    	def addTodo
    		@todos.push Todo.new(@newTodoTitle)
    		@newTodoTitle = ""
    		
    	def toggleTodo todo
    		todo.done = !todo.done
    		console.log "Toggle todo",todo.title
    
    	def render
    import React from 'react';
    import ReactDOM from 'react-dom';
    
    import defaultSlides from './defaultSlides';
    
    const Slider = ({ slides }) => {
      // Create a curr state indicating what's the current slide's index
      const [curr, setCurr] = React.useState(0);
      const { length } = slides;
      
      const goToNext = () => {
        // Check if we've reached the final slide in the array
        // If so, go back to 0, else curr + 1
        setCurr(curr === length - 1 ? 0 : curr + 1);
    console.log("Hello from JavaScript");
    <html>
        <head>
            <link rel="stylesheet" href="index.css">
        </head>
        <body>
            <div id="app">
            <p>Enter your name: </p>
            <input v-model="name"/>
            <button @click="greeting='Hello ' + name">Show Greeting</button>
            <p>{{greeting}}</p>
            </div>
            <script src="index.pack.js"></script>
        </body>
    </html>
    // The prime factors of 13195 are 5, 7, 13 and 29.
    
    // What is the largest prime factor of the given number?
    
    function largestPrimeFactor(number) {
      let largestPrime = 0;
      
      const isPrime = num => {
          for (let i = 2; i <= Math.sqrt(num); i++) {
              if (num % i === 0) {
                  return false;
              }
          }
          return num !== 0 && num !== 1;
    import React, {useState, useCallback} from 'react'
    import ReactDOM from 'react-dom'
    import Color from './Color'
    import Letter from './Letter'
    import randomColor from 'randomcolor'
    import randomLetter from 'random-letter'
    
    // Memoization:
    // returning the cached result of expensive operations
    // if the inputs have not changed
    
    // useCallback
    // Pass an inline callback and an array of inputs.
    // useCallback will return a memoized version of the callback that o
    import React from 'react';
    import ReactDOM from 'react-dom';
    
    //Class
    class Main extends React.Component {
      render() {
        return (
          <div>
            <h1>Hello world!</h1>
            <Counter/>
          </div>
        );
      }
    }
    var app = new Vue({ 
        el: '#app',
        data: {
            message: 'Hello Vue!'
        }
    });
    
Showcase your cast to the community by letting us know on Twitter or our Community Chat.