Snippets Collections
export function getDescription(text) {
    if(text.length > 10){
        return text.substring(0, 10) + "..."
    }
    return text
}
function capitalize(word, capitalize) {
        return word.slice(0, 1).toUpperCase() + word.slice(1).toLowerCase();
}

// Sample usage - do not modify
console.log(capitalize("sam")); // "Sam"
console.log(capitalize("ALEX")); // "Alex"
console.log(capitalize("chARLie")); // "Charlie"
const language = "JavaScript";
language.substring(1, 4); //"ava"

function skipFirstCharacter(text) {
return text.substring(1)
}

console.log(skipFirstCharacter("code")); // "code"
const selected = querySelector('selected');
  const prev =
    selected.previousElementSibling || this.modalImages.lastElementChild;
  selected.classList.remove('selected');
  prev.classList.add('selected');
import React, { useState } from 'react';

const Tour = ({ id, image, info, name, price, removeTour }) => {
  const [readMore, setReadMore] = useState(false);
  return (
    <article className="single-tour">
      <img src={image} alt={name} />
      <footer>
        <div className="tour-info">
          <h4>{name}</h4>
          <h4 className="tour-price">${price}</h4>
        </div>
        <p>
          {readMore ? info : `${info.substring(0, 200)}...`}
          <button onClick={() => setReadMore(!readMore)}>
            {readMore ? 'show less' : '  read more'}
          </button>
        </p>
        <button className="delete-btn" onClick={() => removeTour(id)}>
          not interested
        </button>
      </footer>
    </article>
  );
};

export default Tour;
const date = '2021-06-14T08:29:40.886+00:00'
const formattedDate = date.substring(0,date.lastIndexOf('T'))
console.log(formattedDate)

// prints: "2021-06-14"
star

Mon Oct 31 2022 01:26:30 GMT+0000 (Coordinated Universal Time)

#return #true #substring #elipses
star

Mon Oct 31 2022 00:26:12 GMT+0000 (Coordinated Universal Time)

#substring #slice
star

Mon Oct 31 2022 00:07:49 GMT+0000 (Coordinated Universal Time)

#substring
star

Sun Oct 30 2022 23:09:44 GMT+0000 (Coordinated Universal Time)

#react #show #hide #substring #paragraph #content
star

Sun Oct 16 2022 05:13:57 GMT+0000 (Coordinated Universal Time)

#react #show #hide #substring #paragraph #content
star

Thu Jun 17 2021 11:04:08 GMT+0000 (Coordinated Universal Time)

#javascript #strings #substring #lastindexof

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension