Skip to main content

Posts

[BAEKJOON Online Judge + Node.js] 1181: Word sort

This is my first attempt  const input = require ( "fs" ). readFileSync ( "/dev/stdin" ). toString (). split ( " \n " ) ; const count = Number (input[ 0 ]) ; // 13 // 1. shortest word.length // 2. If the length is the same, in alphabetical order // sort() ? let newArr = [] ; // insert all elements in array let shortest = input[ 1 ]. length ; // just initial value for ( let i = 1 ; i <= count ; i ++ ) { newArr . push (input[i]) ; } // remove duplicated elements in array let removedArr = newArr . filter ( ( item , index ) => newArr . indexOf (item) === index) ; removedArr . sort ( ( a , b ) => { return a . length - b . length ; } ) ; console . log (removedArr) ; i cannot get the correct answer as my answer keeps mixing the order like  [  'i',  'no',  'it',  'im',  'but',  'wont',  'more',  'wait',  'yours', 'cannot',  'hesitate' ...

Basic input and output of JavaScript(Node.js)

Goorm (readline module) // Run by Node.js const readline = require ( "readline" ) ; const rl = readline . createInterface ( { input : process .stdin, output : process .stdout, } ) ; let input = [] ; rl . on ( "line" , function ( line ) {     // let num = line.split(' ').map(Number); for one line input . push ( line . trim ()) ; // rl.close(); } ). on ( "close" , function () { const length = parseInt (input[ 0 ]) ; const values = input[ 1 ]. split ( " " ). map ( Number ) ; console . log ( `your length is ${ length } & your arr is ${ values } ` ) ; process . exit () ; } ) ; BackJoon (fs module) let fs = require ( "fs" ) ; let input = fs . readFileSync ( "/dev/stdin" ). toString (). split ( " \n " ) ;

The Complete Guide React by Maximilian - #1 : Getting Started

7. About this course & course outline  Basics & Foundation of React (Introducing key features) Component & Building UIs Events & Data "props" and "state" Styling React Apps & components Styling React Apps & Hooks Advanced concepts   Side Effects. "Refs" & More React Hooks React Context API & Redux Forms HTTP Requests & "Custom Hooks" Routing, Deployment, NextJS & More Summaries & Refreshers  JS Refresher React Summary 

Forkify - Vanilla JS

282. Loading a Recipe from API async/fetch const   showRecipe   =   async   function  () {    try  {      renderSpinner ( recipeContainer );      // 1) Loading recipe      const   res   =   await   fetch (        'https://forkify-api.herokuapp.com/api/v2/recipes/5ed6604591c37cdc054bc886'     ); 283. Rendering the recipe  after making markup html code       recipeContainer . innerHTML   =   '' ;      recipeContainer . insertAdjacentHTML ( 'afterbegin' ,  markup ); 284. Listening for load and hashchange events dynamic id after removing '#' with slice(1)      const   id   =   window . location . hash . slice ( 1 );      renderSpinner ( recipeContainer );      //...

How to get Input case data in Node.JS

Every website provides a different skeleton code to start with.  BOJ const   input   =   require ( "fs" ). readFileSync ( "/dev/stdin" ). toString ( ' \n ' ); console . log ( input ); Programmers - just focus on the code itself, solution function for the logic function   solution ( numbers ) {      var   answer   =  [];      return   answer ; } Groom  const   readline   =   require ( "readline" ); const   rl   =   readline . createInterface ({    input :  process . stdin ,    output :  process . stdout , }); let   data   =  []; rl . on ( "line" ,  function  ( line ) {    data . push ( line );    //console.log(data);    data   =   line . split ( " " ). map (( el )  =>   el );    console . log ( data );    // data =...