0

`

import React from "react";

function Alert(props) {
    const capitalize = (word) => {
    const lower = word.toLowerCase(); 
    let msg = lower.charAt(0).toUppererCase() + lower.slice(1);
    return msg;
   };
     
  return (
    props.alert && (
     <div className={`alert alert-${props.alert.type} alert-dismissible fade show`} 
       role="alert">
      <strong>{capitalize(props.alert.type)}</strong> : {props.alert.msg}
     </div>
    ));
}
export default Alert;

`

I was trying to capitalize the first letter of my props.alert.type. but the console throws an err!! before writing the capitalize function the code was running just fine!! the type is a string "success", had to capitalize "s" but now I have this error before capitalize function I was getting that alert message as I intended. console err msg

mjshubham21
  • 77
  • 1
  • 7

1 Answers1

1

Typo, change

lower.charAt(0).toUppererCase() to lower.charAt(0).toUpperCase()

Naveen
  • 356
  • 2
  • 10
  • 1
    Rather than answering the question, the question should really be closed by flagging the question as being caused by a typo as it's unlikely to really be helpful to anyone else. – phuzi Nov 15 '22 at 13:38